1

I use mariabackup for creating incremental backups on a previously created full backup directory. The full backup is created using the following command:

mariabackup --backup --target-dir=/var/mariadb/backup/

And the subsequent incremental backups are created as follows:

mariabackup --backup --target-dir=/var/mariadb/inc1/ --incremental-basedir=/var/mariadb/backup/

Now everytime I try to restore the backups for testing purposes using mariabackup --prepare --target-dir=/var/mariadb/backup && mariabackup --prepare --target-dir=/var/mariadb/backup --incremental-dir=/var/mariadb/inc1 I get the following error:

error: This incremental backup seems not to be proper for the target. Check 'to_lsn' of the target and 'from_lsn' of the incremental

Indeed to_lsn and from_lsn differ in the target directory and in the incremental backup directory. The strange thing is that the first few incremental backups can be restored without a problem, only subsequent ones make problems (having different lsn numbers).

How come they have different lsn numbers when the same base directory is being used? Has anyone had the same problem and been able to solve it? Any solutions or tips?

Thanks in advance.

manifestor
  • 6,079
  • 7
  • 27
  • 39

2 Answers2

0

I'm seeing two joined commands on your syntax that I haven't tested before.

What I execute is this, and have no problem on the restore (--copy-back) process:

mariabackup --prepare --target-dir=/path/to_full \
--incremental-dir=/path/to_incremental

Then for the restore:

sudo systemctl stop mariadb
sudo rm -rf /var/lib/mysql
mariabackup --copy-back --target-dir=/path/to_full
sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod 755 /var/lib/mysql
sudo systemctl start mariadb

Hope this helps.

Boris

Boris
  • 1
0

A few things here...

If you are not incrementing the target, i.e; inc1, inc2, inc3, ..., and always using inc1 as incremental directory, then it needs to be empty before reuse. The documentation states that the directory should either be empty or absent.

You are re-preparing your base. The following full backup prepare should only be run once:

$ mariabackup --prepare --target-dir=/var/mariadb/backup

Then you would prepare each subsequent incremental backups one after the other:

  • inc1:

    $ mariabackup --prepare --target-dir=/var/mariadb/backup \
    --incremental-dir=/var/mariadb/inc1
    
  • inc2:

    $ mariabackup --prepare --target-dir=/var/mariadb/backup \
    --incremental-dir=/var/mariadb/inc2
    
  • And inc3, inc4...

Also, you have not mentioned which version of mariaDB you are using (check with: mysqld --version). As per the documentation here, mariaDB 10.1 and below your base backup prepare command should have the --apply-log-only option included:

$ mariabackup --prepare --apply-log-only \
   --target-dir=/var/mariadb/backup

And your incremental prepare as well (don't forget inc2, inc3 and so on):

$ mariabackup --prepare --apply-log-only \
   --target-dir=/var/mariadb/backup \
   --incremental-dir=/var/mariadb/inc1

A word of caution; joining commands will run the second regardless of whether the first has failed.

kkyucon
  • 11
  • 3