mysql Percona-XtraBackup backup

全量备份FULL BACKUP
https://www.percona.com/doc/percona-xtrabackup/2.4/backup_scenarios/full_backup.html#preparing-a-backup
 
全量备份CHEETSHEET
下载(示例:centos7下2.4.4版本,用https://www.percona.com/downloads/XtraBackup/LATEST/选择适合版本)
$ wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm
 
安装
yum localinstall percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm
 
卸载
$ yum remove percona-xtrabackup
 
备份
$ 执行备份(innobackupex --defaults-file=/etc/my.cnf --user=root --password='p4ssword' --stream=tar --databases="database_name" /opt/backup/ | gzip > /opt/backup/data-`date +%Y%m%d`.tar.gz;
$ sleep 5;
$ dbfilename=data;
$ 删除前7天的备份(f ind /opt/backup/ -mtime +7 -name "$dbfilename*.tar.gz" -exec rm -rf {} \;
 
$ 解压备份(tar -zxvf data-20180904.tar.gz -C data
 

After you made a backup with the xtrabackup --backup option, you’ll first need to prepare it in order to restore it. Data files are not point-in-time consistent until they’ve been prepared, because they were copied at different times as the program ran, and they might have been changed while this was happening. If you try to start InnoDB with these data files, it will detect corruption and crash itself to prevent you from running on damaged data. The xtrabackup --prepare step makes the files perfectly consistent at a single instant in time, so you can run InnoDB on them.

You can run the prepare operation on any machine; it does not need to be on the originating server or the server to which you intend to restore. You can copy the backup to a utility server and prepare it there.

$ xtrabackup --prepare --target-dir=/data/backups/
 
$ 还原前需要先停掉mysql服务(systemctl stop mysqld [OR] service mysqld stop)
$ 还原前需要先清空/var/lib/mysql目录(rm -rf /var/lib/mysql
$ 执行还原操作( innobackupex --copy-back /path/to/BACKUP-DIR
$ 文件权限还原给mysql(chown -R mysql:mysql /var/lib/mysql
$ 启动mysql服务(systemctl start mysqld [OR] service mysqld start)
 
增量备份INCREMENTAL BACKUP
https://www.percona.com/doc/percona-xtrabackup/2.4/backup_scenarios/incremental_backup.html#incremental-backup
 
 
 

转载于:https://www.cnblogs.com/xiayudashan/p/9583336.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值