pg_export 0.7.7 → 1.0.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +6 -3
  4. data/CHANGELOG.md +11 -0
  5. data/README.md +14 -11
  6. data/bin/pg_export +92 -26
  7. data/lib/pg_export.rb +5 -13
  8. data/lib/pg_export/configuration.rb +18 -18
  9. data/lib/pg_export/container.rb +5 -30
  10. data/lib/pg_export/import.rb +1 -1
  11. data/lib/pg_export/lib/pg_export/factories/cipher_factory.rb +7 -10
  12. data/lib/pg_export/lib/pg_export/factories/ftp_gateway_factory.rb +22 -0
  13. data/lib/pg_export/lib/pg_export/factories/ssh_gateway_factory.rb +22 -0
  14. data/lib/pg_export/lib/pg_export/{adapters/ftp_adapter.rb → gateways/ftp.rb} +11 -8
  15. data/lib/pg_export/lib/pg_export/gateways/ssh.rb +83 -0
  16. data/lib/pg_export/lib/pg_export/listeners/interactive/build_dump.rb +4 -4
  17. data/lib/pg_export/lib/pg_export/listeners/interactive/{close_ftp_connection.rb → close_connection.rb} +1 -1
  18. data/lib/pg_export/lib/pg_export/listeners/interactive/decrypt_dump.rb +2 -2
  19. data/lib/pg_export/lib/pg_export/listeners/interactive/{download_dump_from_ftp.rb → download_dump.rb} +3 -3
  20. data/lib/pg_export/lib/pg_export/listeners/interactive/encrypt_dump.rb +2 -2
  21. data/lib/pg_export/lib/pg_export/listeners/interactive/{fetch_dumps_from_ftp.rb → fetch_dumps.rb} +1 -1
  22. data/lib/pg_export/lib/pg_export/listeners/interactive/{open_ftp_connection.rb → open_connection.rb} +2 -2
  23. data/lib/pg_export/lib/pg_export/listeners/interactive/{remove_old_dumps_from_ftp.rb → remove_old_dumps.rb} +6 -6
  24. data/lib/pg_export/lib/pg_export/listeners/interactive/restore.rb +2 -2
  25. data/lib/pg_export/lib/pg_export/listeners/interactive/select_database.rb +12 -0
  26. data/lib/pg_export/lib/pg_export/listeners/interactive/select_dump.rb +12 -0
  27. data/lib/pg_export/lib/pg_export/listeners/interactive/{upload_dump_to_ftp.rb → upload_dump.rb} +3 -3
  28. data/lib/pg_export/lib/pg_export/listeners/interactive_listener.rb +2 -2
  29. data/lib/pg_export/lib/pg_export/listeners/plain/build_dump.rb +2 -2
  30. data/lib/pg_export/lib/pg_export/listeners/plain/{close_ftp_connection.rb → close_connection.rb} +2 -2
  31. data/lib/pg_export/lib/pg_export/listeners/plain/decrypt_dump.rb +2 -2
  32. data/lib/pg_export/lib/pg_export/listeners/plain/{download_dump_from_ftp.rb → download_dump.rb} +3 -3
  33. data/lib/pg_export/lib/pg_export/listeners/plain/encrypt_dump.rb +2 -2
  34. data/lib/pg_export/lib/pg_export/listeners/plain/fetch_dumps.rb +15 -0
  35. data/lib/pg_export/lib/pg_export/listeners/plain/open_connection.rb +15 -0
  36. data/lib/pg_export/lib/pg_export/listeners/plain/prepare_params.rb +15 -0
  37. data/lib/pg_export/lib/pg_export/listeners/plain/remove_old_dumps.rb +17 -0
  38. data/lib/pg_export/lib/pg_export/listeners/plain/restore.rb +1 -1
  39. data/lib/pg_export/lib/pg_export/listeners/plain/upload_dump.rb +15 -0
  40. data/lib/pg_export/lib/pg_export/listeners/plain_listener.rb +2 -2
  41. data/lib/pg_export/lib/pg_export/operations/{open_ftp_connection.rb → open_connection.rb} +5 -5
  42. data/lib/pg_export/lib/pg_export/operations/{remove_old_dumps_from_ftp.rb → remove_old_dumps.rb} +7 -7
  43. data/lib/pg_export/lib/pg_export/repositories/{ftp_dump_file_repository.rb → gateway_dump_file_repository.rb} +3 -3
  44. data/lib/pg_export/lib/pg_export/repositories/{ftp_dump_repository.rb → gateway_dump_repository.rb} +7 -7
  45. data/lib/pg_export/lib/pg_export/transactions/export_dump.rb +10 -10
  46. data/lib/pg_export/lib/pg_export/transactions/import_dump_interactively.rb +19 -19
  47. data/lib/pg_export/system/boot/config.rb +17 -1
  48. data/lib/pg_export/system/boot/ftp.rb +11 -0
  49. data/lib/pg_export/system/boot/interactive.rb +4 -20
  50. data/lib/pg_export/system/boot/operations.rb +17 -0
  51. data/lib/pg_export/system/boot/plain.rb +3 -20
  52. data/lib/pg_export/system/boot/ssh.rb +11 -0
  53. data/lib/pg_export/version.rb +1 -1
  54. data/pg_export.gemspec +9 -5
  55. metadata +101 -39
  56. data/lib/pg_export/build_logger.rb +0 -21
  57. data/lib/pg_export/lib/pg_export/factories/ftp_adapter_factory.rb +0 -22
  58. data/lib/pg_export/lib/pg_export/listeners/plain/fetch_dumps_from_ftp.rb +0 -15
  59. data/lib/pg_export/lib/pg_export/listeners/plain/open_ftp_connection.rb +0 -15
  60. data/lib/pg_export/lib/pg_export/listeners/plain/remove_old_dumps_from_ftp.rb +0 -17
  61. data/lib/pg_export/lib/pg_export/listeners/plain/upload_dump_to_ftp.rb +0 -15
  62. data/lib/pg_export/system/boot/logger.rb +0 -15
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 1.0.0.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Maicher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-07 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: dry-initializer
14
+ name: bcrypt_pbkdf
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dry-types
28
+ name: dry-initializer
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-struct
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,62 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: dry-types
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ed25519
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: net-scp
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: net-ssh
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
83
139
  - !ruby/object:Gem::Dependency
84
140
  name: tty-prompt
85
141
  requirement: !ruby/object:Gem::Requirement
@@ -154,16 +210,16 @@ dependencies:
154
210
  name: rake
155
211
  requirement: !ruby/object:Gem::Requirement
156
212
  requirements:
157
- - - "~>"
213
+ - - ">="
158
214
  - !ruby/object:Gem::Version
159
- version: '10.0'
215
+ version: 12.3.3
160
216
  type: :development
161
217
  prerelease: false
162
218
  version_requirements: !ruby/object:Gem::Requirement
163
219
  requirements:
164
- - - "~>"
220
+ - - ">="
165
221
  - !ruby/object:Gem::Version
166
- version: '10.0'
222
+ version: 12.3.3
167
223
  - !ruby/object:Gem::Dependency
168
224
  name: rspec
169
225
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +248,7 @@ dependencies:
192
248
  - - "~>"
193
249
  - !ruby/object:Gem::Version
194
250
  version: 0.59.2
195
- description: CLI for creating and exporting PostgreSQL dumps to FTP. Can
251
+ description: CLI for exporting/importing PostgreSQL dumps via FTP/SSH. Can
196
252
  be used for backups or synchronizing databases between production and development
197
253
  environments.
198
254
  email:
@@ -217,44 +273,48 @@ files:
217
273
  - bin/pg_export
218
274
  - bin/setup
219
275
  - lib/pg_export.rb
220
- - lib/pg_export/build_logger.rb
221
276
  - lib/pg_export/configuration.rb
222
277
  - lib/pg_export/container.rb
223
278
  - lib/pg_export/import.rb
224
279
  - lib/pg_export/lib/pg_export/adapters/bash_adapter.rb
225
- - lib/pg_export/lib/pg_export/adapters/ftp_adapter.rb
226
280
  - lib/pg_export/lib/pg_export/entities/dump.rb
227
281
  - lib/pg_export/lib/pg_export/factories/cipher_factory.rb
228
282
  - lib/pg_export/lib/pg_export/factories/dump_factory.rb
229
- - lib/pg_export/lib/pg_export/factories/ftp_adapter_factory.rb
283
+ - lib/pg_export/lib/pg_export/factories/ftp_gateway_factory.rb
284
+ - lib/pg_export/lib/pg_export/factories/ssh_gateway_factory.rb
285
+ - lib/pg_export/lib/pg_export/gateways/ftp.rb
286
+ - lib/pg_export/lib/pg_export/gateways/ssh.rb
230
287
  - lib/pg_export/lib/pg_export/listeners/interactive/build_dump.rb
231
- - lib/pg_export/lib/pg_export/listeners/interactive/close_ftp_connection.rb
288
+ - lib/pg_export/lib/pg_export/listeners/interactive/close_connection.rb
232
289
  - lib/pg_export/lib/pg_export/listeners/interactive/decrypt_dump.rb
233
- - lib/pg_export/lib/pg_export/listeners/interactive/download_dump_from_ftp.rb
290
+ - lib/pg_export/lib/pg_export/listeners/interactive/download_dump.rb
234
291
  - lib/pg_export/lib/pg_export/listeners/interactive/encrypt_dump.rb
235
- - lib/pg_export/lib/pg_export/listeners/interactive/fetch_dumps_from_ftp.rb
236
- - lib/pg_export/lib/pg_export/listeners/interactive/open_ftp_connection.rb
237
- - lib/pg_export/lib/pg_export/listeners/interactive/remove_old_dumps_from_ftp.rb
292
+ - lib/pg_export/lib/pg_export/listeners/interactive/fetch_dumps.rb
293
+ - lib/pg_export/lib/pg_export/listeners/interactive/open_connection.rb
294
+ - lib/pg_export/lib/pg_export/listeners/interactive/remove_old_dumps.rb
238
295
  - lib/pg_export/lib/pg_export/listeners/interactive/restore.rb
239
- - lib/pg_export/lib/pg_export/listeners/interactive/upload_dump_to_ftp.rb
296
+ - lib/pg_export/lib/pg_export/listeners/interactive/select_database.rb
297
+ - lib/pg_export/lib/pg_export/listeners/interactive/select_dump.rb
298
+ - lib/pg_export/lib/pg_export/listeners/interactive/upload_dump.rb
240
299
  - lib/pg_export/lib/pg_export/listeners/interactive_listener.rb
241
300
  - lib/pg_export/lib/pg_export/listeners/plain/build_dump.rb
242
- - lib/pg_export/lib/pg_export/listeners/plain/close_ftp_connection.rb
301
+ - lib/pg_export/lib/pg_export/listeners/plain/close_connection.rb
243
302
  - lib/pg_export/lib/pg_export/listeners/plain/decrypt_dump.rb
244
- - lib/pg_export/lib/pg_export/listeners/plain/download_dump_from_ftp.rb
303
+ - lib/pg_export/lib/pg_export/listeners/plain/download_dump.rb
245
304
  - lib/pg_export/lib/pg_export/listeners/plain/encrypt_dump.rb
246
- - lib/pg_export/lib/pg_export/listeners/plain/fetch_dumps_from_ftp.rb
247
- - lib/pg_export/lib/pg_export/listeners/plain/open_ftp_connection.rb
248
- - lib/pg_export/lib/pg_export/listeners/plain/remove_old_dumps_from_ftp.rb
305
+ - lib/pg_export/lib/pg_export/listeners/plain/fetch_dumps.rb
306
+ - lib/pg_export/lib/pg_export/listeners/plain/open_connection.rb
307
+ - lib/pg_export/lib/pg_export/listeners/plain/prepare_params.rb
308
+ - lib/pg_export/lib/pg_export/listeners/plain/remove_old_dumps.rb
249
309
  - lib/pg_export/lib/pg_export/listeners/plain/restore.rb
250
- - lib/pg_export/lib/pg_export/listeners/plain/upload_dump_to_ftp.rb
310
+ - lib/pg_export/lib/pg_export/listeners/plain/upload_dump.rb
251
311
  - lib/pg_export/lib/pg_export/listeners/plain_listener.rb
252
312
  - lib/pg_export/lib/pg_export/operations/decrypt_dump.rb
253
313
  - lib/pg_export/lib/pg_export/operations/encrypt_dump.rb
254
- - lib/pg_export/lib/pg_export/operations/open_ftp_connection.rb
255
- - lib/pg_export/lib/pg_export/operations/remove_old_dumps_from_ftp.rb
256
- - lib/pg_export/lib/pg_export/repositories/ftp_dump_file_repository.rb
257
- - lib/pg_export/lib/pg_export/repositories/ftp_dump_repository.rb
314
+ - lib/pg_export/lib/pg_export/operations/open_connection.rb
315
+ - lib/pg_export/lib/pg_export/operations/remove_old_dumps.rb
316
+ - lib/pg_export/lib/pg_export/repositories/gateway_dump_file_repository.rb
317
+ - lib/pg_export/lib/pg_export/repositories/gateway_dump_repository.rb
258
318
  - lib/pg_export/lib/pg_export/transactions/export_dump.rb
259
319
  - lib/pg_export/lib/pg_export/transactions/import_dump_interactively.rb
260
320
  - lib/pg_export/lib/pg_export/types.rb
@@ -262,9 +322,11 @@ files:
262
322
  - lib/pg_export/lib/pg_export/ui/plain/input.rb
263
323
  - lib/pg_export/lib/pg_export/value_objects/dump_file.rb
264
324
  - lib/pg_export/system/boot/config.rb
325
+ - lib/pg_export/system/boot/ftp.rb
265
326
  - lib/pg_export/system/boot/interactive.rb
266
- - lib/pg_export/system/boot/logger.rb
327
+ - lib/pg_export/system/boot/operations.rb
267
328
  - lib/pg_export/system/boot/plain.rb
329
+ - lib/pg_export/system/boot/ssh.rb
268
330
  - lib/pg_export/version.rb
269
331
  - pg_export.gemspec
270
332
  homepage: https://github.com/maicher/pg_export
@@ -282,12 +344,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
282
344
  version: 2.3.0
283
345
  required_rubygems_version: !ruby/object:Gem::Requirement
284
346
  requirements:
285
- - - ">="
347
+ - - ">"
286
348
  - !ruby/object:Gem::Version
287
- version: '0'
349
+ version: 1.3.1
288
350
  requirements: []
289
- rubygems_version: 3.1.2
351
+ rubygems_version: 3.2.3
290
352
  signing_key:
291
353
  specification_version: 4
292
- summary: CLI for creating and exporting PostgreSQL dumps to FTP.
354
+ summary: CLI for exporting/importing PostgreSQL dumps via FTP/SSH.
293
355
  test_files: []
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'logger'
4
-
5
- class PgExport
6
- class BuildLogger
7
- FORMATS = {
8
- plain: ->(_, _, _, message) { "#{message}\n" },
9
- muted: ->(*) { raise 'Do not initialize logger when it is muted' },
10
- timestamped: lambda do |severity, datetime, progname, message|
11
- "#{datetime} #{Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{progname} #{severity}: #{message}\n"
12
- end
13
- }.freeze
14
-
15
- def self.call(stream:, format:)
16
- Logger.new(stream).tap do |logger|
17
- logger.formatter = FORMATS.fetch(format.to_sym)
18
- end
19
- end
20
- end
21
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # auto_register: false
4
-
5
- require 'pg_export/lib/pg_export/adapters/ftp_adapter'
6
- require 'pg_export/import'
7
-
8
- class PgExport
9
- module Factories
10
- class FtpAdapterFactory
11
- include Import['config']
12
-
13
- def ftp_adapter
14
- ::PgExport::Adapters::FtpAdapter.new(
15
- host: config.ftp_host,
16
- user: config.ftp_user,
17
- password: config.ftp_password
18
- )
19
- end
20
- end
21
- end
22
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../plain_listener'
4
-
5
- class PgExport
6
- module Listeners
7
- class Plain
8
- class FetchDumpsFromFtp < PlainListener
9
- def on_step_succeeded(step_name:, args:, value:)
10
- logger.info("Fetch dumps (#{value[:dumps].count} items)")
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../plain_listener'
4
-
5
- class PgExport
6
- module Listeners
7
- class Plain
8
- class OpenFtpConnection < PlainListener
9
- def on_step_succeeded(step_name:, args:, value:)
10
- logger.info("Connect to #{value[:ftp_adapter]}")
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../plain_listener'
4
-
5
- class PgExport
6
- module Listeners
7
- class Plain
8
- class RemoveOldDumpsFromFtp < PlainListener
9
- def on_step_succeeded(step_name:, args:, value:)
10
- value[:removed_dumps].each do |filename|
11
- logger.info("Remove #{filename} from #{value[:ftp_adapter]}")
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../plain_listener'
4
-
5
- class PgExport
6
- module Listeners
7
- class Plain
8
- class UploadDumpToFtp < PlainListener
9
- def on_step_succeeded(step_name:, args:, value:)
10
- logger.info("Upload #{value[:dump]} to #{value[:ftp_adapter]}")
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- PgExport::Container.boot :logger do
4
- init do
5
- require 'pg_export/build_logger'
6
- end
7
-
8
- start do
9
- use :config
10
-
11
- register(:logger, memoize: true) do
12
- PgExport::BuildLogger.call(stream: $stdout, format: target[:config].logger_format)
13
- end
14
- end
15
- end