Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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: ::
Expand All @@ -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
^^^^^^^^^^^^^^^^^^
Expand All @@ -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.


Expand Down
15 changes: 10 additions & 5 deletions xtrabackup/command_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions xtrabackup/restoration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[--log-file=<log>] \
[--out-file=<log>] \
[--backup-threads=<threads>] \
[--no-service-stop] \
[--uncompressed-archives]
pyxtrabackup-restore (-h | --help)
pyxtrabackup --version
Expand Down Expand Up @@ -41,6 +42,8 @@
Output file [default: /var/log/mysql/xtrabackup.out].
--backup-threads=<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.
Expand All @@ -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'],
Expand Down
20 changes: 11 additions & 9 deletions xtrabackup/restoration_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down