Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoration of INCR fails #29

Closed
tilt86 opened this issue Sep 9, 2015 · 5 comments
Closed

Restoration of INCR fails #29

tilt86 opened this issue Sep 9, 2015 · 5 comments

Comments

@tilt86
Copy link

tilt86 commented Sep 9, 2015

Hello,

I'm trying this nice wrapper, but I'm facing an issue when I want to restore an incremental backup, if the number of the incremental backup is > 0.

Here is the folder containing backups: (I've put inside binlog because it's where I have more space on this server)
root@server:/var/lib/mysql/binlog/backup# ls STOR/20150909/INC/ -lth

total 99M
-rw-r--r-- 1 root root 1.2M Sep 9 15:52 inc_2_backup_20150909_1551.tar.gz
-rw-r--r-- 1 root root 833K Sep 9 15:48 inc_1_backup_20150909_1547.tar.gz
-rw-r--r-- 1 root root 510K Sep 9 15:38 inc_0_backup_20150909_1537.tar.gz
-rw-r--r-- 1 root root 96M Sep 9 15:28 base_backup_20150909_1527.tar.gz

Then, if I want to restore up to inc_0, I have no error, but I'm not sure it applied inc_0 ??
root@server:/var/lib/mysql/binlog/backup# pyxtrabackup-restore --base-archive=/var/lib/mysql/binlog/backup/STOR/20150909/INC/base_backup_20150909_1527.tar.gz --incremental-archive=/var/lib/mysql/binlog/backup/STOR/20150909/INC/inc_0_backup_20150909_1547.tar.gz --user=root --password=XXXX --data-dir=/var/lib/mysql/data/db

INFO:xtrabackup.restoration_tools:Base backup restoration time: 0:00:09.813355 - Duration: 9
INFO:xtrabackup.restoration_tools:Backup final preparation time: 0:00:22.981678 - Duration: 22

I can test if the data are consistent however.

But If I want to restore up to inc_0, which I want to to, I got errors...
root@server:/var/lib/mysql/binlog/backup# pyxtrabackup-restore --base-archive=/var/lib/mysql/binlog/backup/STOR/20150909/INC/base_backup_20150909_1527.tar.gz --incremental-archive=/var/lib/mysql/binlog/backup/STOR/20150909/INC/inc_1_backup_20150909_1547.tar.gz --user=root --password=XXXX --data-dir=/var/lib/mysql/data/db

2015-09-09 16:11:43,409 - INFO - Base backup restoration time: 0:00:09.012996 - Duration: 9
2015-09-09 16:11:43,719 - ERROR - An error occured during an incremental backup restoration.
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/xtrabackup/restoration_tools.py", line 94, in apply_incremental_backup
extracted_archive_path)
File "/usr/local/lib/python3.4/dist-packages/xtrabackup/command_executor.py", line 64, in exec_incremental_preparation
self.exec_command(command)
File "/usr/local/lib/python3.4/dist-packages/xtrabackup/command_executor.py", line 16, in exec_command
raise ProcessError(command, process.returncode)
xtrabackup.exception.ProcessError: The following command failed : ['innobackupex', '--apply-log', '--redo-only', '--incremental-dir=/tmp/pyxtrabackup-restore/inc_1_archive', '/var/lib/mysql/data/db'] - Status code: 1
2015-09-09 16:11:43,888 - ERROR - An error occured during the incremental backups restoration process.
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/xtrabackup/restoration_tools.py", line 71, in restore_incremental_backups
self.apply_incremental_backup(repository, step)
File "/usr/local/lib/python3.4/dist-packages/xtrabackup/restoration_tools.py", line 94, in apply_incremental_backup
extracted_archive_path)
File "/usr/local/lib/python3.4/dist-packages/xtrabackup/command_executor.py", line 64, in exec_incremental_preparation
self.exec_command(command)
File "/usr/local/lib/python3.4/dist-packages/xtrabackup/command_executor.py", line 16, in exec_command
raise ProcessError(command, process.returncode)
xtrabackup.exception.ProcessError: The following command failed : ['innobackupex', '--apply-log', '--redo-only', '--incremental-dir=/tmp/pyxtrabackup-restore/inc_1_archive', '/var/lib/mysql/data/db'] - Status code: 1

Did I do something wrong?
I tried with both python 2.7 and 3.4.

Thanks,
Luc

@deviantony
Copy link
Owner

Hi @tilt86,

First, sorry for the late answer. If you look at the --out-file (default: /var/log/mysql/xtrabackup.out), you should see a more precise error. Can you have a look?

@bertalanimre
Copy link

What does your mysql log say? For me, browsing that log, basically solved my issue.

@tilt86
Copy link
Author

tilt86 commented Nov 23, 2015

Hi,

I don't have anymore the server where I used t, but if I reuse it again, I
will check another time.

2015-11-23 18:06 GMT+01:00 bertalanimre notifications@github.com:

What does your mysql log say? For me, browsing that log, basically solved
my issue.


Reply to this email directly or view it on GitHub
#29 (comment)
.

--

LP

@drak25
Copy link

drak25 commented Mar 19, 2016

I may have a clue why incremental restoraion failes, cause i got a problem with it as well.

There is this function

def restore_incremental_backups(self, incremental_archive):
    try:
        repository, archive_name = filesystem_utils.split_path(
            incremental_archive)
        incremental_target = int(archive_name.split('_')[1])
        for step in range(1, incremental_target + 1):

in restoration_tools.py

And i believe there is bug here.

Incremental backups are indexed from 0 so i do not know why you create a range from 1.

When i changed it to for step in range(0, incremental_target + 1):

it started working correctly.

@deviantony
Copy link
Owner

I actually just tested an incremental backup it using the pyxtrabackup-inc binary and it creates the following file structure (tested in a Docker container):

> docker run --rm -it -v "${PWD}:/src" pyxtrabackup zsh
root on 7bee038cf695 in /
$ workon python3
(python3) root on 7bee038cf695 in /
$ pip install --editable /src/
Obtaining file:///src
Requirement already satisfied (use --upgrade to upgrade): docopt in /root/.python_envs/python3/lib/python3.4/site-packages (from pyxtrabackup==3.1.4)
Requirement already satisfied (use --upgrade to upgrade): requests in /root/.python_envs/python3/lib/python3.4/site-packages (from pyxtrabackup==3.1.4)
Installing collected packages: pyxtrabackup
  Running setup.py develop for pyxtrabackup
Successfully installed pyxtrabackup
(python3) root on 7bee038cf695 in /
$ service mysql start
 * Starting MySQL database server mysqld                                                                                                                                                                                                [ OK ] 
 * Checking for tables which need an upgrade, are corrupt or were 
not closed cleanly.
(python3) root on 7bee038cf695 in /
$ mkdir /tmp/backup_repository
(python3) root on 7bee038cf695 in /
$ pyxtrabackup-inc /tmp/backup_repository --user=root
INFO:xtrabackup.backup_tools:Backup time: 0:00:02.037952 - Duration: 2
INFO:xtrabackup.backup_tools:Backup archiving time: 0:00:00.180842 - Duration: 0
INFO:xtrabackup.backup_tools:Archive copy time: 0:00:00.000215 - Duration: 0
(python3) root on 7bee038cf695 in /
$ pyxtrabackup-inc --incremental /tmp/backup_repository --user=root
INFO:xtrabackup.backup_tools:Incremental backup time: 0:00:02.078538 - Duration: 2
INFO:xtrabackup.backup_tools:Backup archiving time: 0:00:00.039583 - Duration: 0
INFO:xtrabackup.backup_tools:Archive copy time: 0:00:00.000242 - Duration: 0
(python3) root on 7bee038cf695 in /
$ pyxtrabackup-inc --incremental /tmp/backup_repository --user=root
INFO:xtrabackup.backup_tools:Incremental backup time: 0:00:02.103087 - Duration: 2
INFO:xtrabackup.backup_tools:Backup archiving time: 0:00:00.040284 - Duration: 0
INFO:xtrabackup.backup_tools:Archive copy time: 0:00:00.000223 - Duration: 0
(python3) root on 7bee038cf695 in /
$ ll /tmp/backup_repository 
total 4.0K
drwxr-xr-x 3 root root 4.0K Mar 23 06:23 20160323
(python3) root on 7bee038cf695 in /
$ ll /tmp/backup_repository/20160323 
total 4.0K
drwxr-xr-x 2 root root 4.0K Mar 23 06:24 INC
(python3) root on 7bee038cf695 in /
$ ll /tmp/backup_repository/20160323/INC 
total 612K
-rw-r--r-- 1 root root 226K Mar 23 06:23 base_backup_20160323_0623.tar.gz
-rw-r--r-- 1 root root 189K Mar 23 06:24 inc_0_backup_20160323_0624.tar.gz
-rw-r--r-- 1 root root 189K Mar 23 06:24 inc_1_backup_20160323_0624.tar.gz

A restoration test shows that an incremental backup restoration step is missing indeed:

(python3) root on 7bee038cf695 in /
$ pyxtrabackup-restore --base-archive /tmp/backup_repository/20160323/INC/base_backup_20160323_0623.tar.gz --incremental-archive /tmp/backup_repository/20160323/INC/inc_1_backup_20160323_0624.tar.gz --user root
INFO:xtrabackup.restoration_tools:Base backup restoration time: 0:00:00.654160 - Duration: 0
INFO:xtrabackup.restoration_tools:Incremental step #1 restoration time: 0:00:01.115791 - Duration: 1
INFO:xtrabackup.restoration_tools:Backup final preparation time: 0:00:04.189706 - Duration: 4

I'm investigating on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants