Search code examples
mysqlbackuppercona

Percona XtraBackup - restoring a database backup into a MySQL server containing other databases


I am trying to migrate a large MySQL database using Percona XtraBackup (15 Gb).

The default innobackupex command to restore a backup requires moving or deleting the mysql datadir (/var/lib/mysql) :

mkdir /tmp/mysql
cd /var/lib/mysql/; mv * /tmp/mysql/
innobackupex --user=user --password=password --copy-back /data/backups/new_backup

The destination MySQL server is already containing several databases. Is there a way to restore the database alongside the existing databases (there will be no schema name conflict)?

TIA


Solution

  • It is indeed possible to restore a database using innobackup/xtrabackup to a running MySQL server.

    Instead of using --copy-back use --export and import each tablespace one at a time. This is easily scripted.

    xtrabackup --export will create .exp, .ibd, and .cfg files.