Backing Up MySQL with Percona Xtrabackup

05/25/2012

You can create a MySQL backup with Percona Xtrabackup by running:
$ innobackupex --user=DBUSER --password=DBUSERPASS /path/to/BACKUP-DIR/

You can then restore the backup with:

$ xtrabackup --prepare --datadir=/var/lib/mysql --target-dir=/path/to/BACKUP-DIR/
$ sudo service mysql stop
$ sudo mv /var/lib/mysql ~/dbbackup
$ sudo mv /path/to/BACKUP-DIR /var/lib/mysql
$ sudo chown -R mysql:mysql /var/lib/mysql
$ sudo service mysql start
$ mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'password from /etc/mysql/debian.cnf' WITH GRANT OPTION;
Be Sociable, Share!