diff --git a/README.rst b/README.rst index a57eafd..e8ab253 100644 --- a/README.rst +++ b/README.rst @@ -129,7 +129,7 @@ Restoration *WARNING*: The folder structure and the file names created by the *pyxtrabackup-inc* binary needs to be respected in order to restore successfully: * TIMESTAMP_FOLDER/INC/base_backup_DATETIME.tar(.gz) - * TIMESTAMP_FOLDER/INC/inc_1_backup_DATETIME.tar(.gz) + * TIMESTAMP_FOLDER/INC/inc_0_backup_DATETIME.tar(.gz) * TIMESTAMP_FOLDER/INC/inc_N_backup_DATETIME.tar(.gz) To restore an incremental backup, you'll need to use the *pyxtrabackup-restore* binary the following way: :: @@ -146,7 +146,7 @@ For example, using the following parameters: :: $ pyxtrabackup-restore --base-archive=/tmp/repo/20140518/INC/base_backup_20140518_1700.tar.gz --incremental-archive=/tmp/repo/20140518/INC/inc_backup_5_20140518_2200.gz --user=backup-user -The script will restore the inc_N_backup_DATETIME.tar.gz from 1 to 5. +The script will restore the inc_N_backup_DATETIME.tar.gz from 0 to 5. Additional options ^^^^^^^^^^^^^^^^^^ @@ -159,6 +159,7 @@ You can also specify the following options: * --log-file: Log file for the script (default: */var/log/mysql/pyxtrabackup-restore.log*). * --out-file: Log file for innobackupex output (default: */var/log/mysql/xtrabackup.out*). * --backup-threads: You can specify more threads in order to backup quicker (default: 1). +* --no-service-stop: Don't stop mysqld service during restore process. * --uncompressed-archives: Do not try to uncompress backup archives. Use this option if you used the backup tool with --no-compress. diff --git a/xtrabackup/command_executor.py b/xtrabackup/command_executor.py index b216d3a..f0d0e50 100644 --- a/xtrabackup/command_executor.py +++ b/xtrabackup/command_executor.py @@ -45,12 +45,17 @@ def exec_incremental_backup(self, user, password, self.exec_command(command) def exec_backup_preparation(self, backup_directory, redo_logs): - command = [ - 'innobackupex', - '--apply-log', - backup_directory] if redo_logs: - command.append('--redo-only') + command = [ + 'innobackupex', + '--apply-log', + '--redo-only', + backup_directory] + else: + command = [ + 'innobackupex', + '--apply-log', + backup_directory] self.exec_command(command) def exec_incremental_preparation(self, backup_directory, diff --git a/xtrabackup/restoration.py b/xtrabackup/restoration.py index 1a807d2..9e0015d 100644 --- a/xtrabackup/restoration.py +++ b/xtrabackup/restoration.py @@ -11,6 +11,7 @@ [--log-file=] \ [--out-file=] \ [--backup-threads=] \ +[--no-service-stop] \ [--uncompressed-archives] pyxtrabackup-restore (-h | --help) pyxtrabackup --version @@ -41,6 +42,8 @@ Output file [default: /var/log/mysql/xtrabackup.out]. --backup-threads= \ Threads count [default: 1]. + --no-service-stop \ + Don't stop mysqld service during restore process. --uncompressed-archives \ Specify that the backup archives are not compressed. \ Use this option if you did backup with --no-compress. @@ -57,6 +60,7 @@ def main(): restore_tool = RestorationTool(arguments['--log-file'], arguments['--out-file'], arguments['--data-dir'], + arguments['--no-service-stop'], arguments['--uncompressed-archives']) try: restore_tool.start_restoration(arguments['--base-archive'], diff --git a/xtrabackup/restoration_tools.py b/xtrabackup/restoration_tools.py index 73735e0..1c0b8c2 100644 --- a/xtrabackup/restoration_tools.py +++ b/xtrabackup/restoration_tools.py @@ -8,12 +8,13 @@ class RestorationTool: - def __init__(self, log_file, output_file, data_dir, uncompressed_archives): + def __init__(self, log_file, output_file, data_dir, no_service_stop, uncompressed_archives): self.log_manager = log_manager.LogManager() self.data_dir = data_dir self.stop_watch = timer.Timer() self.setup_logging(log_file) self.command_executor = CommandExecutor(output_file) + self.service_stop = not no_service_stop self.compressed_archives = not uncompressed_archives def setup_logging(self, log_file): @@ -26,14 +27,15 @@ def prepare_workdir(self, path): self.logger.debug("Temporary workdir: " + self.workdir) def stop_service(self): - try: - self.command_executor.exec_manage_service('mysql', 'stop') - except: - self.logger.error( - 'Unable to manage MySQL service.', - exc_info=True) - self.clean() - raise + if self.service_stop: + try: + self.command_executor.exec_manage_service('mysql', 'stop') + except: + self.logger.error( + 'Unable to manage MySQL service.', + exc_info=True) + self.clean() + raise def clean_data_dir(self): try: