- MariaDB Cookbook
- Daniel Bartholomew
- 383字
- 2021-07-16 12:19:23
Making backups with XtraBackup
XtraBackup is a backup tool from Percona.
Getting ready
The precompiled XtraBackup packages are only available for Linux. Percona provides both YUM and APT repositories.
You can follow the XtraBackup installation instructions on the Percona website available at http://www.percona.com/doc/percona-xtrabackup/. Also, create a backup user by following the instructions in the Creating a backup user recipe.
How to do it...
Let's get started by following the ensuing steps:
- Run the following command by changing the
--user
,--password
, and/path/to/backups
parts to the correct values:sudo innobackupex --user=backupuser \ --password=p455w0rd /path/to/backups
- The
innobackupex
script will callXtraBackup
and copy all of the files to a timestamped subdirectory of the specified backup directory. When it has finished, if everything went well, it will print a line similar to the following line of output:130729 12:05:12 innobackupex: completed OK!
How it works...
The innobackupex
script is a wrapper around XtraBackup
. By itself, the XtraBackup
program only backs up InnoDB and XtraDB databases. When the innobackupex
script is used, MyISAM, Aria, and other non-InnoDB tables are also backed up.
There's more...
Backups created by XtraBackup
and the innobackupex
scripts are not ready to be used to restore a database as is. Backups must be prepared prior to restoring. There are also some things that we need to be aware of when backing up to an NFS-mounted disk.
In order to prepare an XtraBackup
backup to be restored, we must first prepare it as follows:
sudo innobackupex --apply-log /path/to/backups
Then, we can restore it with the following command:
sudo innobackupex --copy-back /path/to/backup
As with running the script for the initial backup, look for the completed OK!
message at the end of the preparing and restoring steps.
The innobackupex
script will refuse to overwrite the files in the data
directory, so it must be empty before a restore can happen.
As a final step, we will also likely need to fix permissions on the restored files with something similar to the following command:
sudo chown -R mysql:mysql /var/lib/mysql
- SOA實(shí)踐
- C語(yǔ)言程序設(shè)計(jì)案例精粹
- 你不知道的JavaScript(中卷)
- 從零開始學(xué)Linux編程
- 基于ARM Cortex-M4F內(nèi)核的MSP432 MCU開發(fā)實(shí)踐
- 智能手機(jī)故障檢測(cè)與維修從入門到精通
- Kotlin極簡(jiǎn)教程
- jQuery技術(shù)內(nèi)幕:深入解析jQuery架構(gòu)設(shè)計(jì)與實(shí)現(xiàn)原理
- Node.js區(qū)塊鏈開發(fā)
- 奔跑吧 Linux內(nèi)核
- Visual Basic語(yǔ)言程序設(shè)計(jì)基礎(chǔ)(第3版)
- Android智能手機(jī)APP界面設(shè)計(jì)實(shí)戰(zhàn)教程
- Java EE項(xiàng)目應(yīng)用開發(fā)
- HTML5 WebSocket權(quán)威指南
- Visual Basic語(yǔ)言程序設(shè)計(jì)上機(jī)指導(dǎo)與練習(xí)(第3版)