This section provides guidelines on how to restore MySQL-based backup taken by Backup Ninja.
Full mysqldump backup restore
1. Decompress the backup with gunzip
:
$ cat /path/to/backup.tar.gz | gunzip > backup.tar.decompressed
2. Restore the backup by redirecting the input to MySQL client like a privileged user e.g, root:
$ cat backup.tar.decrypted_decompressed | mysql -h127.0.0.1 -uroot -p
1. To decrypt a backup, it’s recommended to disable command history (using set +o history
) when specifying the encryption key to decrypt and decompress the backup:
$ set +o history
$ bartender decrypt -k {the-encryption-key} -f /path/to/backup.tar.gz -x -o backup.tar.decrypted_decompressed
$ set -o history
If the backup is not compressed, remove the -x
flag from the command above.
2. Restore the backup by redirecting the input to MySQL client like a privileged user e.g, root:
$ cat backup.tar.decrypted_decompressed | mysql -h127.0.0.1 -uroot -p
Physical backup restore using Percona Xtrabackup/MariaDB Backup
1. Decompress the backup:
$ cat /path/to/backup.tar.gz | gunzip > backup.tar.decompressed
Ignore this step if the backup is not compressed.
2. Restore the uncompress backup. For Percona Xtrabackup, the command is:
$ cat backup.tar.decompressed | xbstream -x -C /path/to/data-dir
While for MariaDB Backup, use mbstream
instead:
$ cat backup.tar.decompressed | mbstream -x -C /path/to/data-dir
3. Apply the InnoDB log files to make the backup consistent again:
$ innobackupex --apply-log /path/to/data-dir
4. Make sure the ownership is for user/group MySQL
:
$ chown -rf mysql:mysql /path/to/data-dir
5. Restart the database service:
For MySQL/Percona Server:
$ service mysql restart # SysVinit
$ systemctl restart mysql # systemd
For MariaDB Server:
$ service mariadb restart # SysVinit
$ systemctl restart mariadb # systemd
The service name might be different depending on the operating system, database package and database version.
1. To decrypt a backup, it’s recommended to disable command history (using set +o history) when specifying the encryption key to decrypt and decompress the backup:
$ set +o history
$ bartender decrypt -k {the-encryption-key} -f /path/to/backup.tar.gz -x -o backup.tar.decrypted_decompressed
$ set -o history
If the backup is not compressed, remove the -x
flag from the command above.
2. Restore the uncompress backup. For Percona Xtrabackup, the command is:
$ cat backup.tar.decompressed | xbstream -x -C /path/to/data-dir
While for MariaDB Backup, use mbstream
instead:
$ cat backup.tar.decompressed | mbstream -x -C /path/to/data-dir
3. Apply the InnoDB log files to make the backup consistent again:
$ innobackupex --apply-log /path/to/data-dir
4. Make sure the ownership is for user/group MySQL
:
$ chown -rf mysql:mysql /path/to/data-dir
5. Restart the database service:
For MySQL/Percona Server:
$ service mysql restart # SysVinit
$ systemctl restart mysql # systemd
For MariaDB Server:
$ service mariadb restart # SysVinit
$ systemctl restart mariadb # systemd
The service name might be different depending on the operating system, database package and database version.