bin/mogbak in mogbak-0.1.2 vs bin/mogbak in mogbak-0.2.0
- old
+ new
@@ -24,12 +24,17 @@
require "mogilefs"
require 'sqlite3'
require 'yaml'
require 'forkinator'
require 'path_helper'
+require 'signal_handler'
+require 'log'
+#activate signal handler
+SignalHandler.instance
+
#Set master process name
$0 = "mogbak [master]"
include GLI
program_desc 'Backup a mogilefs domain to the filesystem. mogbak needs SELECT access to your MogileFS tracker database, which must
@@ -100,19 +105,29 @@
arg_name '[backup_path]'
command :backup do |c|
c.desc 'do not remove deleted files from the backup (faster)'
c.switch ['no-delete']
+ c.desc 'after backup is complete, start another backup. This causes mogbak to run non-stop. Send SIGINT or SIGTERM to exit cleanly'
+ c.switch ['non-stop']
+
c.desc 'Number of worker processes'
c.default_value 1
c.flag :workers
+ c.desc 'send backup output to log file'
+ c.flag ['log-file']
+
c.action do |global_options, options, args|
raise '[backup_path] is required - see: mogbak help backup' unless args[0]
$backup_path = args[0]
+
+ #setup a logger for output
+ Log.instance(options[:'log-file'])
+
mog = Backup.new(:backup_path => args[0], :workers => options[:workers].to_i)
- mog.backup(:no_delete => options[:"no-delete"])
+ mog.backup(:no_delete => options[:"no-delete"], :non_stop => options[:"non-stop"])
end
end
desc 'Restore a backup to a new MogileFS domain.'
@@ -140,15 +155,21 @@
c.flag :workers
c.desc 'restore a single file by dkey'
c.flag :"single-file"
+ c.desc 'send restore output to log file'
+ c.flag ['log-file']
+
c.action do |global_options, options, args|
raise 'domain parameter is required - see: mogbak help restore' unless options[:domain]
raise '[backup_path] is required - see: mogbak help restore' unless args[0]
$backup_path = args[0]
+ #setup a logger for output
+ Log.instance(options[:'log-file'])
+
restore = Restore.new(:tracker_ip => options[:trackerip],
:tracker_port => options[:trackerport],
:domain => options[:domain],
:backup_path => args[0],
:workers => options[:workers])
@@ -160,21 +181,31 @@
long_desc <<EOS
Output is: fid,dkey,length,classname
EOS
arg_name '[backup_path]'
command :list do |c|
+
+ c.desc 'send list output to log file'
+ c.flag ['log-file']
+
c.action do |global_options, options, args|
raise '[backup_path] is required - see: mogbak help list' unless args[0]
$backup_path = args[0]
+ #setup a logger for output
+ Log.instance(options[:'log-file'])
+
list = List.new(:backup_path => args[0])
list.list
end
end
-#If the user passes in --debug we can detect it here.
+#Handle --debug
pre do |global_options, command, options, args|
+
+ #This is used to enable some more verbose output
$debug = global_options[:debug]
+
true
end
#If debug is enabled we'll spit out the exception and the entire backtrace. Otherwise it will just output
#the exception message