pg_export 0.7.4 → 1.0.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +6 -3
- data/CHANGELOG.md +18 -0
- data/README.md +14 -11
- data/bin/pg_export +72 -16
- data/lib/pg_export/configuration.rb +12 -8
- data/lib/pg_export/container.rb +17 -8
- data/lib/pg_export/import.rb +1 -1
- data/lib/pg_export/lib/pg_export/factories/ftp_gateway_factory.rb +22 -0
- data/lib/pg_export/lib/pg_export/factories/ssh_gateway_factory.rb +22 -0
- data/lib/pg_export/lib/pg_export/{adapters/ftp_adapter.rb → gateways/ftp.rb} +11 -8
- data/lib/pg_export/lib/pg_export/gateways/ssh.rb +82 -0
- data/lib/pg_export/lib/pg_export/listeners/interactive/build_dump.rb +4 -4
- data/lib/pg_export/lib/pg_export/listeners/interactive/{close_ftp_connection.rb → close_connection.rb} +1 -1
- data/lib/pg_export/lib/pg_export/listeners/interactive/decrypt_dump.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/interactive/download_dump_from_ftp.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/interactive/encrypt_dump.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/interactive/{open_ftp_connection.rb → open_connection.rb} +1 -1
- data/lib/pg_export/lib/pg_export/listeners/interactive/remove_old_dumps_from_ftp.rb +5 -5
- data/lib/pg_export/lib/pg_export/listeners/interactive/restore.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/interactive/upload_dump_to_ftp.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/interactive_listener.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/plain/build_dump.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/plain/{close_ftp_connection.rb → close_connection.rb} +2 -2
- data/lib/pg_export/lib/pg_export/listeners/plain/decrypt_dump.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/plain/download_dump_from_ftp.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/plain/encrypt_dump.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/plain/fetch_dumps_from_ftp.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/plain/open_connection.rb +15 -0
- data/lib/pg_export/lib/pg_export/listeners/plain/remove_old_dumps_from_ftp.rb +3 -3
- data/lib/pg_export/lib/pg_export/listeners/plain/restore.rb +1 -1
- data/lib/pg_export/lib/pg_export/listeners/plain/upload_dump_to_ftp.rb +2 -2
- data/lib/pg_export/lib/pg_export/listeners/plain_listener.rb +2 -2
- data/lib/pg_export/lib/pg_export/operations/{open_ftp_connection.rb → open_connection.rb} +5 -5
- data/lib/pg_export/lib/pg_export/operations/remove_old_dumps_from_ftp.rb +6 -6
- data/lib/pg_export/lib/pg_export/repositories/{ftp_dump_file_repository.rb → gateway_dump_file_repository.rb} +3 -3
- data/lib/pg_export/lib/pg_export/repositories/{ftp_dump_repository.rb → gateway_dump_repository.rb} +7 -7
- data/lib/pg_export/lib/pg_export/transactions/export_dump.rb +8 -8
- data/lib/pg_export/lib/pg_export/transactions/import_dump_interactively.rb +14 -14
- data/lib/pg_export/lib/pg_export/types.rb +1 -1
- data/lib/pg_export/system/boot/interactive.rb +1 -1
- data/lib/pg_export/system/boot/plain.rb +2 -2
- data/lib/pg_export/version.rb +1 -1
- data/pg_export.gemspec +13 -9
- metadata +88 -31
- data/lib/pg_export/lib/pg_export/factories/ftp_adapter_factory.rb +0 -22
- data/lib/pg_export/lib/pg_export/listeners/plain/open_ftp_connection.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96c2a7a23f195dba8cb7e21e3de8d9d130fd5849291e68ed153892b1f9e7aef6
|
4
|
+
data.tar.gz: 6f3fe11961d2d6b2089b6abacf93a1f37e48deee88d697c8402a9ac73b3dbbd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 320d541ded251f9053bffa686fb429e22572b306f48227cb9b51aaa4bae76fd452ce2ab8e8f84ac63a0b1b4628bc8c70fbfbfb26d2295d5fc7bd1c1f9188330f
|
7
|
+
data.tar.gz: db3b2d4799b5ddc7e0628070b8d99406655d7fc3111a34a93dc8237a189ea01ef004a72d8ed2716ad03d74b901ec597d4dc796c9e893b0557e0f698639788a48
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
3
2
|
rvm:
|
4
|
-
-
|
3
|
+
- 3.0.0
|
4
|
+
- 2.7.2
|
5
|
+
- 2.4.10
|
6
|
+
services:
|
7
|
+
- postgresql
|
5
8
|
addons:
|
6
9
|
code_climate:
|
7
10
|
repo_token: db03e5968c5bcd68b12ca50f5d41ae07dd74fe80d4e1421d754e31c316e7477a
|
8
|
-
before_install: gem install bundler -v
|
11
|
+
before_install: gem install bundler -v 2.2.3
|
9
12
|
after_success: codeclimate-test-reporter
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
### 1.0.0 - 2021.03.20
|
2
|
+
- Make it compatible with Ruby 3.0
|
3
|
+
- Change configuration envs:
|
4
|
+
- BACKUP_FTP_HOST -> PG_EXPORT_GATEWAY_HOST
|
5
|
+
- BACKUP_FTP_USER -> PG_EXPORT_GATEWAY_USER
|
6
|
+
- BACKUP_FTP_PASSWORD -> PG_EXPORT_GATEWAY_PASSWORD
|
7
|
+
- DUMP_ENCRYPTION_KEY -> PG_EXPORT_ENCRYPTION_KEY
|
8
|
+
- Drop Ruby 2.3 support
|
9
|
+
- Add SSH option
|
10
|
+
|
11
|
+
### 0.7.7 - 2020.09.07
|
12
|
+
|
13
|
+
- Upgrade dry-initializer
|
14
|
+
|
15
|
+
### 0.7.6 - 2020.09.05
|
16
|
+
|
17
|
+
- Upgrade dry-types, dry-struct dry-system
|
18
|
+
|
1
19
|
### 0.7.0 - 2018.10.18
|
2
20
|
|
3
21
|
- Change required ruby version from 2.2.0 to 2.3.0.
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ Features:
|
|
26
26
|
|
27
27
|
## Dependencies
|
28
28
|
|
29
|
-
* Ruby >= 2.3.0
|
29
|
+
* Ruby >= 2.4 (works with Ruby 3.0)
|
30
30
|
* $ pg_dump
|
31
31
|
* $ pg_restore
|
32
32
|
|
@@ -51,29 +51,32 @@ Or install it yourself as:
|
|
51
51
|
$ pg_export -h
|
52
52
|
|
53
53
|
Usage: pg_export [options]
|
54
|
+
-g, --gateway GATEWAY [Optional] ssh or ftp (default: ftp)
|
54
55
|
-d, --database DATABASE [Required] Name of the database to export
|
55
56
|
-k, --keep [KEEP] [Optional] Number of dump files to keep on FTP (default: 10)
|
56
57
|
-t, --timestamped [Optional] Enables log messages with timestamps
|
57
58
|
-m, --muted [Optional] Mutes log messages (overrides -t option)
|
58
59
|
-i, --interactive [Optional] Interactive command line mode - for restoring dumps into databases
|
60
|
+
-v, --version Show version
|
59
61
|
-h, --help Show this message
|
60
|
-
|
62
|
+
|
61
63
|
Setting can be verified by running following commands:
|
62
64
|
-c, --configuration Prints the configuration
|
63
|
-
-
|
65
|
+
-w, --welcome Tries connecting to the gateway (FTP or SSH) to verify the connection
|
66
|
+
|
64
67
|
|
65
68
|
## How to start
|
66
69
|
|
67
70
|
__Step 1.__ Prepare ENV variables.
|
68
71
|
|
69
72
|
/* FTP storage for database dumps. */
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
+
PG_EXPORT_GATEWAY_HOST=yourftp.example.com
|
74
|
+
PG_EXPORT_GATEWAY_USER=user
|
75
|
+
PG_EXPORT_GATEWAY_PASSWORD=password
|
73
76
|
|
74
|
-
/* Encryption key
|
77
|
+
/* Encryption key should have exactly 16 characters. */
|
75
78
|
/* Dumps will be SSL(AES-128-CBC) encrypted using this key. */
|
76
|
-
|
79
|
+
PG_EXPORT_ENCRYPTION_KEY=1234567890abcdef
|
77
80
|
|
78
81
|
/* Dumps to be kept on FTP */
|
79
82
|
/* Optional, defaults to 10 */
|
@@ -84,12 +87,12 @@ Note, that variables cannot include `#` sign, [more info](http://serverfault.com
|
|
84
87
|
__Step 2.__ Print the configuration to verify if env variables has been loaded properly.
|
85
88
|
|
86
89
|
$ pg_export --configuration
|
87
|
-
=> {:dump_encryption_key=>"k4***", :
|
88
|
-
:
|
90
|
+
=> {:dump_encryption_key=>"k4***", :gateway_host=>"yourftp.example.com", :gateway_user=>"your_gateway_user",
|
91
|
+
:gateway_password=>"pass***", :logger_format=>"plain", :keep_dumps=>2}
|
89
92
|
|
90
93
|
__Step 3.__ Try connecting to FTP to verify the connection.
|
91
94
|
|
92
|
-
$ pg_export --ftp
|
95
|
+
$ pg_export --gateway ftp --welcome
|
93
96
|
=> 230 User your_ftp_user logged in
|
94
97
|
|
95
98
|
__Step 4.__ Perform database export.
|
data/bin/pg_export
CHANGED
@@ -4,65 +4,121 @@
|
|
4
4
|
require 'optparse'
|
5
5
|
|
6
6
|
require 'pg_export'
|
7
|
-
require 'pg_export/container'
|
8
7
|
|
9
8
|
ENV['KEEP_DUMPS'] = ENV['KEEP_DUMPS'] || '10'
|
9
|
+
ENV['GATEWAY'] = 'ftp'
|
10
|
+
|
10
11
|
interactive = false
|
11
12
|
database = nil
|
12
13
|
|
14
|
+
|
13
15
|
option_parser = OptionParser.new do |opts|
|
14
|
-
opts.banner =
|
16
|
+
opts.banner = <<~TXT
|
17
|
+
NAME
|
18
|
+
pg_export - CLI for exporting/importing PostgreSQL dumps via FTP/SSH
|
19
|
+
|
20
|
+
SYNOPSIS (default mode)
|
21
|
+
pg_export DATABASE [options]
|
22
|
+
|
23
|
+
SYNOPSIS (interactive mode)
|
24
|
+
pg_export --interactive [DATABASE] [options]
|
25
|
+
|
26
|
+
ARGUMENTS
|
27
|
+
DATABASE - database name to export (when default mode)
|
28
|
+
- phrase to filter database dumps by (when interactive mode)
|
29
|
+
|
30
|
+
OPTIONS
|
31
|
+
TXT
|
32
|
+
|
33
|
+
opts.on('-g', '--gateway GATEWAY', String, 'ssh or ftp (default: ftp) - credentials need to be set via ENVs') do |g|
|
34
|
+
ENV['GATEWAY'] = g
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on('-s', '--ssh', 'Same as "--gateway ssh"') do
|
38
|
+
ENV['GATEWAY'] = 'ssh'
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on('-f', '--ftp', 'Same as "--gateway ftp"') do
|
42
|
+
ENV['GATEWAY'] = 'ftp'
|
43
|
+
end
|
15
44
|
|
16
|
-
opts.on('-d', '--database DATABASE', String, '
|
45
|
+
opts.on('-d', '--database DATABASE', String, 'Alternative way of specifying name of the database to export or phrase to filter by') do |d|
|
17
46
|
database = d
|
18
47
|
end
|
19
48
|
|
20
|
-
opts.on('-
|
49
|
+
opts.on('-e', '--encryption_key KEY', String, 'Dumps will be SSL(AES-128-CBC) encrypted using this key. Should have exactly 16 characters. Overwrites PG_EXPORT_ENCRYPTION_KEY env') do |key|
|
50
|
+
ENV['PG_EXPORT_ENCRYPTION_KEY'] = key
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on('-k', '--keep KEEP', String, "Number of dump files to keep on FTP (default: 10). Overwrites KEEP_DUMPS env") do |keep|
|
21
54
|
ENV['KEEP_DUMPS'] = keep
|
22
55
|
end
|
23
56
|
|
24
|
-
opts.on('-t', '--timestamped', '
|
57
|
+
opts.on('-t', '--timestamped', 'Enables log messages with timestamps') do
|
25
58
|
ENV['LOGGER_FORMAT'] = 'timestamped'
|
26
59
|
end
|
27
60
|
|
28
|
-
opts.on('-m', '--muted', '
|
61
|
+
opts.on('-m', '--muted', 'Mutes log messages (overrides -t option)') do
|
29
62
|
ENV['LOGGER_FORMAT'] = 'muted'
|
30
63
|
end
|
31
64
|
|
32
|
-
opts.on('-i', '--interactive', '
|
65
|
+
opts.on('-i', '--interactive', 'Interactive mode, for importing dumps') do
|
33
66
|
interactive = true
|
34
67
|
end
|
35
68
|
|
69
|
+
opts.on('-v', '--version', 'Show version') do
|
70
|
+
puts PgExport::VERSION
|
71
|
+
exit
|
72
|
+
end
|
73
|
+
|
36
74
|
opts.on('-h', '--help', 'Show this message') do
|
37
75
|
puts opts
|
38
76
|
exit
|
39
77
|
end
|
40
78
|
|
41
|
-
opts.separator
|
79
|
+
opts.separator <<~TXT
|
80
|
+
|
81
|
+
ENV
|
82
|
+
PG_EXPORT_GATEWAY_HOST required
|
83
|
+
PG_EXPORT_GATEWAY_USER required
|
84
|
+
PG_EXPORT_GATEWAY_PASSWORD optional when eg. authorized key is added
|
85
|
+
PG_EXPORT_ENCRYPTION_KEY required or set by --encryption_key)
|
86
|
+
TXT
|
87
|
+
|
88
|
+
opts.separator "\nTEST RUN"
|
42
89
|
|
43
|
-
opts.on('-c', '--configuration', '
|
90
|
+
opts.on('-c', '--configuration', 'Print the configuration') do
|
91
|
+
require 'pg_export/container'
|
44
92
|
PgExport::Container.start(:config)
|
45
93
|
puts PgExport::Container['config'].to_h
|
46
94
|
exit
|
47
95
|
end
|
48
96
|
|
49
|
-
opts.on('-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
puts
|
97
|
+
opts.on('-w', '--welcome', 'Try connecting to the gateway (FTP or SSH) to verify the connection') do
|
98
|
+
require 'pg_export/container'
|
99
|
+
PgExport::Container.start(ENV['GATEWAY'].to_sym)
|
100
|
+
gateway = PgExport::Container['factories.gateway_factory'].gateway
|
101
|
+
puts gateway.welcome
|
102
|
+
exit
|
103
|
+
end
|
104
|
+
|
105
|
+
if ARGV.empty?
|
106
|
+
puts opts
|
54
107
|
exit
|
55
108
|
end
|
56
109
|
end
|
57
110
|
|
58
111
|
begin
|
59
112
|
option_parser.parse!
|
113
|
+
database = ARGV.first unless ARGV.empty?
|
60
114
|
rescue OptionParser::ParseError => e
|
61
115
|
warn e.message.capitalize
|
62
|
-
warn 'Type "pg_export
|
116
|
+
warn 'Type "pg_export" for available options'
|
63
117
|
exit
|
64
118
|
end
|
65
119
|
|
120
|
+
require 'pg_export/container'
|
121
|
+
|
66
122
|
begin
|
67
123
|
pg_export =
|
68
124
|
if interactive
|
@@ -78,5 +134,5 @@ end
|
|
78
134
|
|
79
135
|
pg_export.call(database) do |result|
|
80
136
|
result.success { puts 'Success' }
|
81
|
-
result.failure { |
|
137
|
+
result.failure { |outcome| warn outcome[:message] }
|
82
138
|
end
|
@@ -5,21 +5,21 @@ require 'dry-struct'
|
|
5
5
|
|
6
6
|
class PgExport
|
7
7
|
class Configuration < Dry::Struct
|
8
|
-
include Dry::Types
|
8
|
+
include Dry::Types()
|
9
9
|
|
10
10
|
attribute :dump_encryption_key, Strict::String.constrained(size: 16)
|
11
|
-
attribute :
|
12
|
-
attribute :
|
13
|
-
attribute :
|
11
|
+
attribute :gateway_host, Strict::String
|
12
|
+
attribute :gateway_user, Strict::String
|
13
|
+
attribute :gateway_password, Strict::String.optional
|
14
14
|
attribute :logger_format, Coercible::String.enum('plain', 'timestamped', 'muted')
|
15
15
|
attribute :keep_dumps, Coercible::Integer.constrained(gteq: 0)
|
16
16
|
|
17
17
|
def self.build(env)
|
18
18
|
new(
|
19
|
-
dump_encryption_key: env['
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
dump_encryption_key: env['PG_EXPORT_ENCRYPTION_KEY'],
|
20
|
+
gateway_host: env['PG_EXPORT_GATEWAY_HOST'],
|
21
|
+
gateway_user: env['PG_EXPORT_GATEWAY_USER'],
|
22
|
+
gateway_password: env['PG_EXPORT_GATEWAY_PASSWORD'] == '' ? nil : env['PG_EXPORT_GATEWAY_PASSWORD'],
|
23
23
|
logger_format: env['LOGGER_FORMAT'] || 'plain',
|
24
24
|
keep_dumps: env['KEEP_DUMPS'] || 10
|
25
25
|
)
|
@@ -27,6 +27,10 @@ class PgExport
|
|
27
27
|
raise PgExport::InitializationError, e.message.gsub('[PgExport::Configuration.new] ', '')
|
28
28
|
end
|
29
29
|
|
30
|
+
def gateway
|
31
|
+
ENV['GATEWAY'].to_sym
|
32
|
+
end
|
33
|
+
|
30
34
|
def logger_muted?
|
31
35
|
logger_format == 'muted'
|
32
36
|
end
|
data/lib/pg_export/container.rb
CHANGED
@@ -16,32 +16,41 @@ class PgExport
|
|
16
16
|
|
17
17
|
boot(:ftp) do
|
18
18
|
init do
|
19
|
-
require 'pg_export/lib/pg_export/factories/
|
19
|
+
require 'pg_export/lib/pg_export/factories/ftp_gateway_factory'
|
20
20
|
end
|
21
21
|
|
22
22
|
start do
|
23
23
|
use :config
|
24
|
+
register('factories.gateway_factory') { ::PgExport::Factories::FtpGatewayFactory.new }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
boot(:ssh) do
|
29
|
+
init do
|
30
|
+
require 'pg_export/lib/pg_export/factories/ssh_gateway_factory'
|
31
|
+
end
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
start do
|
34
|
+
use :config
|
35
|
+
register('factories.gateway_factory') { ::PgExport::Factories::SshGatewayFactory.new }
|
28
36
|
end
|
29
37
|
end
|
30
38
|
|
31
|
-
boot(:main) do
|
39
|
+
boot(:main) do |system|
|
32
40
|
init do
|
33
41
|
require 'pg_export/lib/pg_export/operations/encrypt_dump'
|
34
42
|
require 'pg_export/lib/pg_export/operations/decrypt_dump'
|
35
43
|
require 'pg_export/lib/pg_export/operations/remove_old_dumps_from_ftp'
|
36
|
-
require 'pg_export/lib/pg_export/operations/
|
44
|
+
require 'pg_export/lib/pg_export/operations/open_connection'
|
37
45
|
end
|
38
46
|
|
39
47
|
start do
|
40
|
-
use
|
48
|
+
use(system[:config].gateway)
|
49
|
+
|
41
50
|
register('operations.encrypt_dump') { ::PgExport::Operations::EncryptDump.new }
|
42
51
|
register('operations.decrypt_dump') { ::PgExport::Operations::DecryptDump.new }
|
43
52
|
register('operations.remove_old_dumps_from_ftp') { ::PgExport::Operations::RemoveOldDumpsFromFtp.new }
|
44
|
-
register('operations.
|
53
|
+
register('operations.open_connection') { ::PgExport::Operations::OpenConnection.new }
|
45
54
|
end
|
46
55
|
end
|
47
56
|
end
|
data/lib/pg_export/import.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# auto_register: false
|
4
|
+
|
5
|
+
require 'pg_export/lib/pg_export/gateways/ftp'
|
6
|
+
require 'pg_export/import'
|
7
|
+
|
8
|
+
class PgExport
|
9
|
+
module Factories
|
10
|
+
class FtpGatewayFactory
|
11
|
+
include Import['config']
|
12
|
+
|
13
|
+
def gateway
|
14
|
+
::PgExport::Gateways::Ftp.new(
|
15
|
+
host: config.gateway_host,
|
16
|
+
user: config.gateway_user,
|
17
|
+
password: config.gateway_password
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# auto_register: false
|
4
|
+
|
5
|
+
require 'pg_export/lib/pg_export/gateways/ssh'
|
6
|
+
require 'pg_export/import'
|
7
|
+
|
8
|
+
class PgExport
|
9
|
+
module Factories
|
10
|
+
class SshGatewayFactory
|
11
|
+
include Import['config']
|
12
|
+
|
13
|
+
def gateway
|
14
|
+
::PgExport::Gateways::Ssh.new(
|
15
|
+
host: config.gateway_host,
|
16
|
+
user: config.gateway_user,
|
17
|
+
password: config.gateway_password
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -5,28 +5,31 @@
|
|
5
5
|
require 'net/ftp'
|
6
6
|
|
7
7
|
class PgExport
|
8
|
-
module
|
9
|
-
class
|
8
|
+
module Gateways
|
9
|
+
class Ftp
|
10
10
|
CHUNK_SIZE = (2**16).freeze
|
11
11
|
|
12
12
|
def initialize(host:, user:, password:)
|
13
13
|
@host, @user, @password, @logger = host, user, password
|
14
|
-
ObjectSpace.define_finalizer(self, proc { ftp.close if @ftp })
|
15
14
|
end
|
16
15
|
|
17
|
-
def
|
16
|
+
def open
|
18
17
|
@ftp = Net::FTP.new(host, user, password)
|
19
18
|
@ftp.passive = true
|
20
19
|
@ftp
|
21
20
|
end
|
22
21
|
|
23
|
-
def
|
22
|
+
def welcome
|
23
|
+
open.welcome
|
24
|
+
end
|
25
|
+
|
26
|
+
def close
|
24
27
|
@ftp&.close
|
25
28
|
end
|
26
29
|
|
27
|
-
def list(
|
30
|
+
def list(name)
|
28
31
|
ftp
|
29
|
-
.list(
|
32
|
+
.list([name, '*'].join('_'))
|
30
33
|
.map { |row| extracted_meaningful_attributes(row) }
|
31
34
|
.sort_by { |item| item[:name] }
|
32
35
|
.reverse
|
@@ -49,7 +52,7 @@ class PgExport
|
|
49
52
|
end
|
50
53
|
|
51
54
|
def ftp
|
52
|
-
@ftp ||=
|
55
|
+
@ftp ||= open
|
53
56
|
end
|
54
57
|
|
55
58
|
private
|