Skip to content

Restore MySQL database with Percona Xtrabackup

November 1, 2022 | 08:22 PM

MYSQL BACKUP restore

Preparation

Create a temp folder on the restore server. Think of it as a working area for your restore task.

Move files from backup target to restore server: rsync -avrP

Place full and inc backups in separate folders.

IMPORTANT

Requirements restore server:

MySQL server version latest or at least same as current instance. Percona xtrabackup current version for OS.

Update the OS as necessary and be certain of the correct version:

mysql -V

Restore

MySQL service needs to be stopped.

/var/lib/mysql needs to be empty.

Prepare backups files on the restore server:

xtrabackup --prepare --apply-log-only --target-dir=/ path to full backup

Add increments -> oldest to latest

xtrabackup --prepare --apply-log-only --target-di=/ path to full backup --incremental-dir=/ path to inc

Move files to /var/lib/mysql with rsync -avrP

Make certain that all the files have been assigned user and group mysql.

chown mysql:mysql mysql /var/lib/mysql -R

Then proceed and start MySQL:

service mysql start

After restore has been performed successfully

Remember to clean up all temporary files and directories.

Read more: https://www.percona.com/software/mysql-database/percona-xtrabackup