pxcbackup 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fad7cc2f34cb4b40039125ce85ccef409914a53
4
- data.tar.gz: 63404f369242c5b9f402dbe7e2b08bc534778c3f
3
+ metadata.gz: 4919b371225d61db6d40812129a705252c3df03b
4
+ data.tar.gz: b4a720f44e75ae89f902ea2f795c98c8e88d5074
5
5
  SHA512:
6
- metadata.gz: 215382dea8914c3ec1d89e07727dcbbbf01434299dc4fb60e464153ac8fa52c7de909c83e578031fe8f4596b6d74b14ca56fd8a3300bae29315dba0db01b2ddc
7
- data.tar.gz: dd937751742df0aec5e88549e457a911faa458722350414e9f70c2dfcb70e3644ad3b46f69be572bad37afdc72297ddecfef1d75fda4333008bf4dd6e36b4133
6
+ metadata.gz: 2f9daa68cdaeac728543a34133843e26c28bcb98f9f1581e992de4545df87bd1c89d5c659400194335a302c484f547c35561b2685591cb05ed374a300bfa596b
7
+ data.tar.gz: 022bccdaf48c27937246ef113f9bd9d478c48ee580a6ea111dd7b40ec13c88860de8aa94de8f052604fbb066cc825ff66b99fdc7083d4a6d3af92950a76aa51e
@@ -34,7 +34,7 @@ module PXCBackup
34
34
  backupper.list_backups
35
35
  when 'restore'
36
36
  time = @arguments.any? ? Time.parse(@arguments.first) : Time.now
37
- backupper.restore_backup(time, !!@options[:skip_confirmation])
37
+ backupper.restore_backup(time, @options)
38
38
  end
39
39
  end
40
40
 
@@ -44,17 +44,13 @@ module PXCBackup
44
44
  opt.banner = "Usage: #{$0} COMMAND [OPTIONS]"
45
45
  opt.separator ''
46
46
  opt.separator 'Commands'
47
- opt.separator ' create create a new backup'
48
- opt.separator ' help show this help'
49
- opt.separator ' list list available backups'
50
- opt.separator ' restore [time] restore to a point in time'
47
+ opt.separator ' create create a new backup'
48
+ opt.separator ' help show this help'
49
+ opt.separator ' list list available backups'
50
+ opt.separator ' restore [time] restore to a point in time'
51
51
  opt.separator ''
52
52
  opt.separator 'Options'
53
53
 
54
- opt.on('--no-color', 'disable color output') do |color_output|
55
- @options[:no_color] = true
56
- end
57
-
58
54
  opt.on('-c', '--config', '=CONFIG_FILE', 'config file to use instead of ~/.pxcbackup') do |config_file|
59
55
  @options[:config] = config_file
60
56
  end
@@ -75,6 +71,10 @@ module PXCBackup
75
71
  @options[:local] = true
76
72
  end
77
73
 
74
+ opt.on('--no-color', 'disable color output') do
75
+ @options[:no_color] = true
76
+ end
77
+
78
78
  opt.on('-r', '--remote', '=REMOTE_URI', 'remote URI to sync backups to, e.g. s3://my-aws-bucket/') do |remote|
79
79
  @options[:remote] = remote
80
80
  end
@@ -95,7 +95,11 @@ module PXCBackup
95
95
  end
96
96
  end
97
97
 
98
- def restore_backup(time, skip_confirmation = false)
98
+ def restore_backup(time, options = {})
99
+ skip_confirmation = options[:skip_confirmation] || false
100
+ mysql_start_command = options[:mysql_start_command] || "#{@which.service.shellescape} mysql start"
101
+ mysql_stop_command = options[:mysql_stop_command] || "#{@which.service.shellescape} mysql stop"
102
+
99
103
  incremental_backups = []
100
104
  all_backups.reverse_each do |backup|
101
105
  incremental_backups.unshift(backup) if backup.time <= time
@@ -206,7 +210,7 @@ module PXCBackup
206
210
  end
207
211
 
208
212
  Logger.action 'Stopping MySQL server' do
209
- Command.run("#{@which.service.shellescape} mysql stop")
213
+ Command.run(mysql_stop_command)
210
214
  end
211
215
 
212
216
  stat = File.stat(mysql_datadir)
@@ -228,13 +232,16 @@ module PXCBackup
228
232
  end
229
233
 
230
234
  if @local_repo
231
- Logger.action "Removing last backup info" do
232
- File.delete(File.join(@local_repo.path, 'xtrabackup_checkpoints'))
235
+ xtrabackup_checkpoints_file = File.join(@local_repo.path, 'xtrabackup_checkpoints')
236
+ if File.file?(xtrabackup_checkpoints_file)
237
+ Logger.action "Removing last backup info" do
238
+ File.delete(xtrabackup_checkpoints_file)
239
+ end
233
240
  end
234
241
  end
235
242
 
236
243
  Logger.action 'Starting MySQL server' do
237
- Command.run("#{@which.service.shellescape} mysql start")
244
+ Command.run(mysql_start_command)
238
245
  end
239
246
  end
240
247
  end
@@ -342,6 +349,9 @@ module PXCBackup
342
349
  Command.run(command)
343
350
  end
344
351
 
352
+ xtrabackup_binary_file = File.join(dir, 'xtrabackup_binary')
353
+ File.delete(xtrabackup_binary_file) if File.file?(xtrabackup_binary_file)
354
+
345
355
  info = read_backup_info(File.join(dir, 'xtrabackup_checkpoints'))
346
356
  info[:compress] = Dir.glob(File.join(dir, '**', '*.qp')).any?
347
357
 
@@ -10,7 +10,7 @@ module PXCBackup
10
10
  def method_missing(name, *arguments)
11
11
  unless @paths[name]
12
12
  @paths[name] = @options["#{name.to_s}_path".to_sym] || `which #{name.to_s.shellescape}`.strip
13
- raise "cannot find path for #{name.to_s}" unless File.file?(@paths[name])
13
+ raise "cannot find path for '#{name.to_s}'" unless File.file?(@paths[name])
14
14
  end
15
15
  @paths[name]
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module PXCBackup
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pxcbackup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robbert Klarenbeek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-11 00:00:00.000000000 Z
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Backup tool for Percona XtraDB Cluster
14
14
  email: robbertkl@renbeek.nl