lib/backup/database/mysql.rb in backup-4.1.2 vs lib/backup/database/mysql.rb in backup-4.1.3
- old
+ new
@@ -45,10 +45,16 @@
# has more feasible restore times for large databases.
# See: http://www.percona.com/doc/percona-xtrabackup/
attr_accessor :backup_engine
##
+ # If true (which is the default behaviour), the backup will be prepared
+ # after it has been successfuly created. This option is only valid if
+ # :backup_engine is set to :innobackupex.
+ attr_accessor :prepare_backup
+
+ ##
# If set the backup engine command block is executed as the given user
attr_accessor :sudo_user
##
# If set, do not suppress innobackupdb output (useful for debugging)
@@ -58,10 +64,11 @@
super
instance_eval(&block) if block_given?
@name ||= :all
@backup_engine ||= :mysqldump
+ @prepare_backup = true if @prepare_backup.nil?
end
##
# Performs the mysqldump or innobackupex command and outputs
# the dump file in the +dump_path+ using +dump_filename+.
@@ -149,15 +156,20 @@
def innobackupex
# Creation phase
"#{ utility(:innobackupex) } #{ credential_options } " +
"#{ connectivity_options } #{ user_options } " +
"--no-timestamp #{ temp_dir } #{ quiet_option } && " +
- # Log applying phase (prepare for restore)
- "#{ utility(:innobackupex) } --apply-log #{ temp_dir } " +
- "#{ user_prepare_options } #{ quiet_option } && " +
+ innobackupex_prepare +
# Move files to tar-ed stream on stdout
"#{ utility(:tar) } --remove-files -cf - " +
"-C #{ File.dirname(temp_dir) } #{ File.basename(temp_dir) }"
+ end
+
+ def innobackupex_prepare
+ return "" unless @prepare_backup
+ # Log applying phase (prepare for restore)
+ "#{ utility(:innobackupex) } --apply-log #{ temp_dir } " +
+ "#{ user_prepare_options } #{ quiet_option } && "
end
def sudo_option(command_block)
return command_block unless sudo_user