dumpr 1.3 → 1.5
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 +5 -5
- data/History.md +27 -0
- data/README.md +19 -24
- data/dumpr.gemspec +2 -2
- data/lib/dumpr/cli.rb +121 -60
- data/lib/dumpr/driver/mysql.rb +10 -1
- data/lib/dumpr/driver.rb +7 -6
- data/lib/dumpr/util.rb +2 -2
- data/lib/dumpr/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fc389dfe47cee75a1693efcc96b2320f859107abf58456a9cb13730bcd9ff252
|
4
|
+
data.tar.gz: e50b33f103457183f669acac00197fbc6f1751572384d85c6659afda25b45835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeba1bbc43df3747fff76e87f692ea805705acc36b92c96c0d92e41f6cbad8930b32d733aa31b55ceb78298a7ce3adba7d61011aed0b908f9a5177217bcafe85
|
7
|
+
data.tar.gz: a49a759ab2fe9361d2cc32a2c1efe6eec8bf6f639aaf36c7a462eccd6c53fcc000c956b07f511deaaf8a2970852bb45fccfa194501fe9904ace9c3b8de63b1d3
|
data/History.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# HISTORY
|
2
|
+
|
3
|
+
This is the changelog version history for the [dumpr](https://rubygems.org/gems/dumpr) gem.
|
4
|
+
|
5
|
+
## dumpr 1.4
|
6
|
+
|
7
|
+
* Changed `--password` to no longer be required.
|
8
|
+
* Improved `--help` documentation.
|
9
|
+
|
10
|
+
## dumpr 1.3
|
11
|
+
|
12
|
+
* Added support for postgresql with `-t postgres`
|
13
|
+
|
14
|
+
## dumpr 1.2
|
15
|
+
|
16
|
+
* Changed repo name from dumper to dumpr for uniqueness sake.
|
17
|
+
* Added command `dumpr-import`.
|
18
|
+
* Deprecated `dumpr -i` option, replaced by `dumpr-import`.
|
19
|
+
|
20
|
+
## dumpr 1.1
|
21
|
+
|
22
|
+
* Improved usage
|
23
|
+
|
24
|
+
|
25
|
+
## dumpr 1.0
|
26
|
+
|
27
|
+
* Initial release.
|
data/README.md
CHANGED
@@ -5,9 +5,15 @@ Features:
|
|
5
5
|
* generates gzipped sql dump files for a specific database or specific tables.
|
6
6
|
* automates transfer of dump files to remote hosts
|
7
7
|
* automates import
|
8
|
+
* support for MySQL and Postgres.
|
8
9
|
|
9
10
|
Executables installed:
|
10
11
|
* dumpr
|
12
|
+
* dumpr-import
|
13
|
+
|
14
|
+
The current version is [dumpr 1.4](https://rubygems.org/gems/dumpr).
|
15
|
+
|
16
|
+
Recent changes are documented in [History](https://github.com/jamesdickson6/dumpr/blob/master/History.md).
|
11
17
|
|
12
18
|
### Dependencies
|
13
19
|
* [Ruby ≥ 2.2.1](http://www.ruby-lang.org/en/downloads/)
|
@@ -48,23 +54,26 @@ You can write your own scripts that use a *Dumpr::Driver*
|
|
48
54
|
|
49
55
|
### Exporting
|
50
56
|
|
51
|
-
Generate yourdb.sql.gz and transfer it to
|
57
|
+
Generate yourdb.sql.gz and transfer it to another server.
|
58
|
+
|
52
59
|
```ruby
|
53
|
-
Dumpr::Driver::Mysql.
|
54
|
-
:user => 'backupuser',
|
55
|
-
:
|
56
|
-
:
|
60
|
+
Dumpr::Driver::Mysql.dump(
|
61
|
+
:user => 'backupuser',
|
62
|
+
:password => '12345',
|
63
|
+
:db => 'test_database',
|
64
|
+
:destination => 'server2:/data/dumps/test_database.sql'
|
57
65
|
)
|
58
66
|
```
|
59
67
|
|
60
68
|
### Importing
|
61
69
|
|
62
|
-
Then, over on dbserver2
|
70
|
+
Then, over on **dbserver2**, import your dump file.
|
63
71
|
```ruby
|
64
72
|
Dumpr::Driver::Mysql.import(
|
65
|
-
:user => 'importuser',
|
66
|
-
:
|
67
|
-
:
|
73
|
+
:user => 'importuser',
|
74
|
+
:password => '12345',
|
75
|
+
:db => 'test_database',
|
76
|
+
:file => '/data/dumps/test_database.sql'
|
68
77
|
)
|
69
78
|
```
|
70
79
|
|
@@ -72,23 +81,9 @@ Then, over on dbserver2, import your dump file
|
|
72
81
|
|
73
82
|
See *Dumpr::Driver*
|
74
83
|
|
75
|
-
|
76
|
-
## CHANGELOG
|
77
|
-
|
78
|
-
### Version 1.3
|
79
|
-
* Split binary, new command `dumpr-import` to replace `dumpr --import`
|
80
|
-
* Postgres support (beta)
|
81
|
-
|
82
|
-
### Version 1.2
|
83
|
-
* Changed gem and binary command from `dumper` to `dumpr`
|
84
|
-
|
85
|
-
### Version 1.1
|
86
|
-
* Tweaks
|
87
|
-
|
88
|
-
### Version 1.0
|
89
|
-
* Initial release
|
90
84
|
|
91
85
|
## TODO
|
86
|
+
|
92
87
|
* automate importing after an export (socket communication exporter/importer, or just lockfile checking / polling)
|
93
88
|
* security: stop logging passwords
|
94
89
|
* daemonize, maybe?
|
data/dumpr.gemspec
CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Dumpr::Version.to_s
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["James Dickson"]
|
10
|
-
s.email = ["
|
10
|
+
s.email = ["james.dickson@hpe.com"]
|
11
11
|
s.homepage = "http://github.com/jamesdickson6/dumpr"
|
12
12
|
s.summary = "Dump and import databases."
|
13
|
-
s.description = "Dumpr provides an easy way to dump and import databases.
|
13
|
+
s.description = "Dumpr provides an easy way to dump and import databases. Support for MySQL and Postgres databases."
|
14
14
|
s.files = `git ls-files -z`.split("\x0")
|
15
15
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
16
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
data/lib/dumpr/cli.rb
CHANGED
@@ -18,15 +18,27 @@ module Dumpr
|
|
18
18
|
op = OptionParser.new do |opts|
|
19
19
|
|
20
20
|
opts.banner = <<-ENDSTR
|
21
|
-
|
21
|
+
#{PROG_NAME} #{Dumpr::Version}
|
22
22
|
|
23
|
-
|
23
|
+
usage: #{PROG_NAME} [options] [file]
|
24
24
|
|
25
|
-
|
25
|
+
#{PROG_NAME} --user test --db test_example test_example_dump.sql
|
26
26
|
|
27
|
-
|
27
|
+
Create a database dump file, exporting database(s) to a file.
|
28
|
+
The default database type is MySQL. Supports MySQL and Postgres.
|
28
29
|
|
29
|
-
|
30
|
+
arguments:
|
31
|
+
|
32
|
+
[file] File is the filename of the database dump being created.
|
33
|
+
It may be relative, 'mydumpfile.sql' to write to your working directory.
|
34
|
+
It may be absolute, 'server:/path/to/dumpfile.sql'.
|
35
|
+
If server: is specified, ssh/scp is used to transfer data to the remote server.
|
36
|
+
You will want to setup .ssh/config to avoid being prompted for passwords.
|
37
|
+
The .gz file extension is assumed.
|
38
|
+
By default it will first look for a compressed version at [file].gz.
|
39
|
+
The --no-gzip option can be used to skip compression.
|
40
|
+
|
41
|
+
options:
|
30
42
|
|
31
43
|
ENDSTR
|
32
44
|
|
@@ -34,20 +46,20 @@ ENDSTR
|
|
34
46
|
options[:driver] = val
|
35
47
|
end
|
36
48
|
|
37
|
-
opts.on("--
|
38
|
-
options[:all_databases] = val
|
39
|
-
end
|
40
|
-
|
41
|
-
opts.on("--db DATABASE", "--database DATABASE", "Database to dump/import") do |val|
|
49
|
+
opts.on("--db DATABASE", "--database DATABASE", "Dump a single database") do |val|
|
42
50
|
options[:database] = val
|
43
51
|
end
|
44
52
|
|
45
53
|
# TODO: Add support to Driver for this
|
46
|
-
opts.on("--databases x,y,z", Array, "
|
54
|
+
opts.on("--databases x,y,z", Array, "Dump multiple databases") do |val|
|
47
55
|
options[:databases] = val
|
48
56
|
end
|
49
57
|
|
50
|
-
opts.on("--
|
58
|
+
opts.on("--all-databases", "Dump ALL databases") do |val|
|
59
|
+
options[:all_databases] = val
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on("--tables z,y,z", Array, "Dump certain tables, to be used on conjuction with a single --database") do |val|
|
51
63
|
options[:tables] = val
|
52
64
|
end
|
53
65
|
|
@@ -67,23 +79,25 @@ ENDSTR
|
|
67
79
|
options[:port] = val
|
68
80
|
end
|
69
81
|
|
70
|
-
opts.on("--file FILENAME", "Filename of dump to create
|
82
|
+
opts.on("-f FILENAME", "--file FILENAME", "Filename of dump to create, may passed in place of the [file] argument.") do |val|
|
71
83
|
options[:dumpfile] = val
|
72
84
|
end
|
73
85
|
|
74
|
-
|
75
|
-
options[:dumpfile] = val
|
76
|
-
end
|
86
|
+
# could get rid of all these and just rely on full filepath being passed.
|
77
87
|
|
78
|
-
opts.on("--
|
79
|
-
|
80
|
-
end
|
88
|
+
# opts.on("--dumpfile FILENAME", "Alias for --file") do |val|
|
89
|
+
# options[:dumpfile] = val
|
90
|
+
# end
|
81
91
|
|
82
|
-
opts.on("--
|
83
|
-
|
84
|
-
end
|
92
|
+
# opts.on("--destination DESTINATION", "Destination for dumpfile. This can be a remote host:path.") do |val|
|
93
|
+
# options[:destination] = val
|
94
|
+
# end
|
85
95
|
|
86
|
-
opts.on("--
|
96
|
+
# opts.on("--dumpdir DIRECTORY", "Default directory for dumpfiles. Default is working directory") do |val|
|
97
|
+
# options[:dumpdir] = val
|
98
|
+
# end
|
99
|
+
|
100
|
+
opts.on("--dump-options=[OPTIONS]", "Extra options to be included in dump command") do |val|
|
87
101
|
options[:dump_options] = val
|
88
102
|
end
|
89
103
|
|
@@ -105,6 +119,7 @@ ENDSTR
|
|
105
119
|
|
106
120
|
opts.on("-h", "--help", "Show this message") do
|
107
121
|
puts opts
|
122
|
+
print "\n"
|
108
123
|
exit
|
109
124
|
end
|
110
125
|
|
@@ -117,9 +132,22 @@ ENDSTR
|
|
117
132
|
|
118
133
|
begin
|
119
134
|
op.parse!(args)
|
120
|
-
|
121
|
-
|
122
|
-
|
135
|
+
if args.count == 0 && options[:dumpfile].nil?
|
136
|
+
raise OptionParser::InvalidOption.new("[file] or --file is required.")
|
137
|
+
elsif args.count == 1
|
138
|
+
options[:dumpfile] = args[0]
|
139
|
+
else
|
140
|
+
raise OptionParser::NeedlessArgument.new("wrong number of arguments, expected 0-1 and got (#{args.count}) #{args.join(', ')}")
|
141
|
+
end
|
142
|
+
rescue => e
|
143
|
+
case (e)
|
144
|
+
when OptionParser::InvalidOption, OptionParser::AmbiguousOption, OptionParser::MissingArgument, OptionParser::InvalidArgument, OptionParser::NeedlessArgument
|
145
|
+
STDERR.puts "#{e.message}"
|
146
|
+
STDERR.puts "Try -h for help with this command."
|
147
|
+
exit 1
|
148
|
+
else
|
149
|
+
raise e
|
150
|
+
end
|
123
151
|
end
|
124
152
|
|
125
153
|
|
@@ -133,7 +161,7 @@ ENDSTR
|
|
133
161
|
puts "bad arguments: #{e.message}.\n See --help"
|
134
162
|
exit 1
|
135
163
|
rescue Dumpr::DumpFileExists => e
|
136
|
-
puts "#{e.message}\nIt looks like this dump exists already. You should move it, or use --force to
|
164
|
+
puts "#{e.message}\nIt looks like this dump exists already. You should move it, or use --force to overwrite it"
|
137
165
|
exit 1
|
138
166
|
rescue Dumpr::BusyDumping => e
|
139
167
|
puts "#{e.message}\n See --help"
|
@@ -159,15 +187,31 @@ ENDSTR
|
|
159
187
|
op = OptionParser.new do |opts|
|
160
188
|
|
161
189
|
opts.banner = <<-ENDSTR
|
162
|
-
|
190
|
+
#{PROG_NAME} #{Dumpr::Version}
|
191
|
+
|
192
|
+
usage:
|
193
|
+
#{PROG_NAME} [options] [file]
|
163
194
|
|
164
|
-
|
195
|
+
#{PROG_NAME} --user test --db test_example ./test_example_dump.sql
|
165
196
|
|
166
|
-
|
197
|
+
Import a database dump file, restoring data to the specified hosts and database(s).
|
198
|
+
The default database type is MySQL. Supports MySQL and Postgres.
|
199
|
+
WARNING: This command will overwrite your database information.
|
200
|
+
Be sure you specify the correct host and database name(s)
|
201
|
+
and the [file] that contains the data you want in it.
|
167
202
|
|
168
|
-
|
203
|
+
arguments:
|
169
204
|
|
170
|
-
|
205
|
+
[file] File is the path of the database dump file being imported.
|
206
|
+
File may be relative, 'mydumpfile.sql.gz' to read from your working directory.
|
207
|
+
File may be absolute, 'server:/path/to/dumpfile.sql'.
|
208
|
+
If server: is specified, ssh/scp is used to transfer data from the remote server.
|
209
|
+
You will want to setup ssh configuration to avoid password prompts.
|
210
|
+
The .gz file extension is assumed.
|
211
|
+
By default it will first look for a compressed version at [file].gz.
|
212
|
+
The --no-gzip option can be used to skip compression.
|
213
|
+
|
214
|
+
options:
|
171
215
|
|
172
216
|
ENDSTR
|
173
217
|
|
@@ -175,23 +219,24 @@ ENDSTR
|
|
175
219
|
options[:driver] = val
|
176
220
|
end
|
177
221
|
|
178
|
-
opts.on("--
|
179
|
-
options[:all_databases] = val
|
180
|
-
end
|
181
|
-
|
182
|
-
opts.on("--db DATABASE", "--database DATABASE", "Database to dump/import") do |val|
|
222
|
+
opts.on("--db DATABASE", "--database DATABASE", "Import to a single database") do |val|
|
183
223
|
options[:database] = val
|
184
224
|
end
|
185
225
|
|
186
|
-
# TODO:
|
187
|
-
|
226
|
+
# TODO: add support to Driver for --databases and --tables
|
227
|
+
# import probably does not need this right now
|
228
|
+
opts.on("--databases x,y,z", Array, "Import multiple databases") do |val|
|
188
229
|
options[:databases] = val
|
189
230
|
end
|
190
231
|
|
191
|
-
opts.on("--
|
192
|
-
options[:
|
232
|
+
opts.on("--all-databases", "Import ALL databases") do |val|
|
233
|
+
options[:all_databases] = val
|
193
234
|
end
|
194
235
|
|
236
|
+
# opts.on("--tables x,y,z", Array, "Import only certain tables, to be used on conjuction with a single --database") do |val|
|
237
|
+
# options[:tables] = val
|
238
|
+
# end
|
239
|
+
|
195
240
|
opts.on("-u USER", "--user USER", "Database user") do |val|
|
196
241
|
options[:user] = val
|
197
242
|
end
|
@@ -208,23 +253,25 @@ ENDSTR
|
|
208
253
|
options[:port] = val
|
209
254
|
end
|
210
255
|
|
211
|
-
opts.on("--file FILENAME", "Filename of dump to create
|
256
|
+
opts.on("-f FILENAME", "--file FILENAME", "Filename of dump to create, may passed in place of the [file] argument.") do |val|
|
212
257
|
options[:dumpfile] = val
|
213
258
|
end
|
214
259
|
|
215
|
-
|
216
|
-
options[:dumpfile] = val
|
217
|
-
end
|
260
|
+
# could get rid of all these and just rely on full filepath being passed.
|
218
261
|
|
219
|
-
opts.on("--
|
220
|
-
|
221
|
-
end
|
262
|
+
# opts.on("--dumpfile FILENAME", "Alias for --file") do |val|
|
263
|
+
# options[:dumpfile] = val
|
264
|
+
# end
|
222
265
|
|
223
|
-
opts.on("--
|
224
|
-
|
225
|
-
end
|
266
|
+
# opts.on("--destination DESTINATION", "Destination for dump files. This can be a remote host:path.") do |val|
|
267
|
+
# options[:destination] = val
|
268
|
+
# end
|
269
|
+
|
270
|
+
# opts.on("--dumpdir DIRECTORY", "Default directory for dump files. Default is working directory") do |val|
|
271
|
+
# options[:dumpdir] = val
|
272
|
+
# end
|
226
273
|
|
227
|
-
opts.on("--import-options=[
|
274
|
+
opts.on("--import-options=[OPTIONS]", "Extra options to be included in import command") do |val|
|
228
275
|
options[:import_options] = val.to_s
|
229
276
|
end
|
230
277
|
|
@@ -232,20 +279,21 @@ ENDSTR
|
|
232
279
|
options[:gzip] = false
|
233
280
|
end
|
234
281
|
|
235
|
-
opts.on("--gzip-options=[GZIPOPTIONS]", "gzip compression options. Default is -9 (slowest /max compression)") do |val|
|
236
|
-
|
237
|
-
end
|
282
|
+
# opts.on("--gzip-options=[GZIPOPTIONS]", "gzip compression options. Default is -9 (slowest /max compression)") do |val|
|
283
|
+
# options[:gzip_options] = val
|
284
|
+
# end
|
238
285
|
|
239
286
|
opts.on("--log-file LOGFILE", "Log file. Default is stdout.") do |val|
|
240
287
|
options[:log_file] = val
|
241
288
|
end
|
242
289
|
|
243
|
-
opts.on("--force", "Overwrite
|
290
|
+
opts.on("--force", "Overwrite dump file if it exists already.") do |val|
|
244
291
|
options[:force] = val
|
245
292
|
end
|
246
293
|
|
247
294
|
opts.on("-h", "--help", "Show this message") do
|
248
295
|
puts opts
|
296
|
+
print "\n"
|
249
297
|
exit
|
250
298
|
end
|
251
299
|
|
@@ -258,9 +306,22 @@ ENDSTR
|
|
258
306
|
|
259
307
|
begin
|
260
308
|
op.parse!(args)
|
261
|
-
|
262
|
-
|
263
|
-
|
309
|
+
if args.count == 0 && options[:dumpfile].nil?
|
310
|
+
raise OptionParser::InvalidOption.new("[file] or --file is required.")
|
311
|
+
elsif args.count == 1
|
312
|
+
options[:dumpfile] = args[0]
|
313
|
+
else
|
314
|
+
raise OptionParser::NeedlessArgument.new("wrong number of arguments, expected 0-1 and got (#{args.count}) #{args.join(', ')}")
|
315
|
+
end
|
316
|
+
rescue => e
|
317
|
+
case (e)
|
318
|
+
when OptionParser::InvalidOption, OptionParser::AmbiguousOption, OptionParser::MissingArgument, OptionParser::InvalidArgument, OptionParser::NeedlessArgument
|
319
|
+
STDERR.puts "#{e.message}"
|
320
|
+
STDERR.puts "Try -h for help with this command."
|
321
|
+
exit 1
|
322
|
+
else
|
323
|
+
raise e
|
324
|
+
end
|
264
325
|
end
|
265
326
|
|
266
327
|
|
@@ -274,7 +335,7 @@ ENDSTR
|
|
274
335
|
puts "bad arguments: #{e.message}.\n See --help"
|
275
336
|
exit 1
|
276
337
|
rescue Dumpr::DumpFileExists => e
|
277
|
-
puts "#{e.message}\nIt looks like this dump exists already. You should move it, or use --force to
|
338
|
+
puts "#{e.message}\nIt looks like this dump exists already. You should move it, or use --force to overwrite it"
|
278
339
|
exit 1
|
279
340
|
rescue Dumpr::BusyDumping => e
|
280
341
|
puts "#{e.message}\n See --help"
|
data/lib/dumpr/driver/mysql.rb
CHANGED
@@ -43,7 +43,16 @@ module Dumpr
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def import_cmd
|
46
|
-
"mysql -u #{user} --password=#{password} -h #{host} -P #{port} #{database} < #{dumpfile}"
|
46
|
+
#"mysql -u #{user} --password=#{password} -h #{host} -P #{port} #{database} < #{dumpfile}"
|
47
|
+
cmd = ["mysql"]
|
48
|
+
cmd << "-u '#{user}'" unless user.to_s.empty?
|
49
|
+
cmd << "--password '#{password}'" unless password.to_s.empty?
|
50
|
+
cmd << "-h '#{host}'" unless host.to_s.empty?
|
51
|
+
cmd << "-P '#{port}'" unless port.to_s.empty?
|
52
|
+
cmd << "#{database}" unless database.empty?
|
53
|
+
cmd << "#{import_options}" unless import_options.to_s.empty?
|
54
|
+
cmd << " < #{dumpfile}"
|
55
|
+
cmd.join(" ")
|
47
56
|
end
|
48
57
|
|
49
58
|
end
|
data/lib/dumpr/driver.rb
CHANGED
@@ -66,7 +66,8 @@ module Dumpr
|
|
66
66
|
@gzip = opts[:gzip].nil? ? true : opts[:gzip]
|
67
67
|
@gzip_options = opts[:gzip_options] || "-9"
|
68
68
|
@dumpdir = opts[:dumpdir] || Dir.pwd #"./"
|
69
|
-
@dumpfile = (opts[:file] || opts[:dumpfile] || opts[:filename]) or raise BadConfig.new "
|
69
|
+
@dumpfile = (opts[:file] || opts[:dumpfile] || opts[:filename]) or raise BadConfig.new "[file] is required"
|
70
|
+
@dumpfile = @dumpfile.to_s.dup # this is frozen?
|
70
71
|
@dumpfile = @dumpfile[0].chr == "/" ? @dumpfile : File.join(@dumpdir, @dumpfile)
|
71
72
|
@dumpfile.chomp!(".gz")
|
72
73
|
# (optional) :destination is where dumps are exported to, and can be a remote host:path
|
@@ -130,12 +131,12 @@ module Dumpr
|
|
130
131
|
Util.with_lockfile("localhost", dumpfn, @opts[:force]) do
|
131
132
|
|
132
133
|
logger.debug "preparing dump..."
|
133
|
-
if !File.
|
134
|
+
if !File.exist?(File.dirname(dumpfn))
|
134
135
|
run "mkdir -p #{File.dirname(dumpfn)}"
|
135
136
|
end
|
136
137
|
|
137
138
|
# avoid overwriting dump files..
|
138
|
-
if File.
|
139
|
+
if File.exist?(dumpfn)
|
139
140
|
if @opts[:force]
|
140
141
|
logger.warn "#{dumpfn} exists, moving it to #{dumpfn}.1"
|
141
142
|
#run "rm -f #{dumpfn}.1;"
|
@@ -182,8 +183,8 @@ module Dumpr
|
|
182
183
|
end
|
183
184
|
|
184
185
|
def decompress
|
185
|
-
if File.
|
186
|
-
if File.
|
186
|
+
if File.exist?(@dumpfile + ".gz")
|
187
|
+
if File.exist?(@dumpfile) && !@opts[:force]
|
187
188
|
logger.warn "skipping decompress because #{@dumpfile} already exists."
|
188
189
|
else
|
189
190
|
logger.debug "decompressing..."
|
@@ -201,7 +202,7 @@ module Dumpr
|
|
201
202
|
Util.with_lockfile("localhost", @dumpfile, @opts[:force]) do
|
202
203
|
decompress if @gzip
|
203
204
|
|
204
|
-
if !File.
|
205
|
+
if !File.exist?(@dumpfile)
|
205
206
|
raise "Cannot import #{@dumpfile} because it does not exist!"
|
206
207
|
else
|
207
208
|
dumpsize = Util.human_file_size("localhost", @dumpfile)
|
data/lib/dumpr/util.rb
CHANGED
@@ -5,7 +5,7 @@ module Dumpr
|
|
5
5
|
|
6
6
|
def self.file_exists?(h, fn)
|
7
7
|
if h == "localhost"
|
8
|
-
File.
|
8
|
+
File.exist?(fn)
|
9
9
|
else
|
10
10
|
`ssh #{h} test -f '#{fn}' &> /dev/null`
|
11
11
|
$?.success?
|
@@ -14,7 +14,7 @@ module Dumpr
|
|
14
14
|
|
15
15
|
def self.dir_exists?(h, fn)
|
16
16
|
if h == "localhost"
|
17
|
-
File.
|
17
|
+
File.exist?(fn)
|
18
18
|
else
|
19
19
|
`ssh #{h} test -d '#{fn}' &> /dev/null`
|
20
20
|
$?.success?
|
data/lib/dumpr/version.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dumpr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Dickson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Dumpr provides an easy way to dump and import databases.
|
14
|
-
|
13
|
+
description: Dumpr provides an easy way to dump and import databases. Support for
|
14
|
+
MySQL and Postgres databases.
|
15
15
|
email:
|
16
|
-
-
|
16
|
+
- james.dickson@hpe.com
|
17
17
|
executables:
|
18
18
|
- csv2sqlinsert
|
19
19
|
- dumpr
|
@@ -24,6 +24,7 @@ extra_rdoc_files:
|
|
24
24
|
files:
|
25
25
|
- ".gitignore"
|
26
26
|
- Gemfile
|
27
|
+
- History.md
|
27
28
|
- LICENSE
|
28
29
|
- README.md
|
29
30
|
- Rakefile
|
@@ -43,7 +44,7 @@ homepage: http://github.com/jamesdickson6/dumpr
|
|
43
44
|
licenses:
|
44
45
|
- MIT
|
45
46
|
metadata: {}
|
46
|
-
post_install_message:
|
47
|
+
post_install_message:
|
47
48
|
rdoc_options: []
|
48
49
|
require_paths:
|
49
50
|
- lib
|
@@ -58,9 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
59
|
- !ruby/object:Gem::Version
|
59
60
|
version: '0'
|
60
61
|
requirements: []
|
61
|
-
|
62
|
-
|
63
|
-
signing_key:
|
62
|
+
rubygems_version: 3.4.10
|
63
|
+
signing_key:
|
64
64
|
specification_version: 4
|
65
65
|
summary: Dump and import databases.
|
66
66
|
test_files: []
|