标签:增量备份 var pex file log nobackup default my.cnf bash
cat xtrabackup.sh
#!/bin/bash
[ -d /home/increment/ ] || mkdir -p /home/increment/
mysql_path=/home/
mysql_increment_path=/home/increment/
#mysql全备
mysql_backup() {
innobackupex --defaults-file=/etc/my.cnf --user=root --password=‘123456‘ --backup $mysql_path/mysql-`date +%Y%m%d`/ --no-timestamp
exit 0
}
#恢复
mysql_recovery() {
systemctl stop mysqld
mv /var/lib/mysql /var/lib/mysql2
innobackupex --apply-log $mysql_path/mysql-`date +%Y%m%d`/
innobackupex --defaults-file=/etc/my.cnf --copy-back $mysql_path/mysql-`date +%Y%m%d`/
chown -R mysql.mysql /var/lib/mysql
systemctl start mysqld
exit 0
}
#增量备份
mysql_increment() {
innobackupex --defaults-file=/etc/my.cnf --user=root --password=‘123456‘ --incremental $mysql_increment_path/mysql-`date +%Y%m%d`/ --incremental-basedir=$mysql_path/mysql-`date +%Y%m%d`/ --no-timestamp
exit 0
}
#增量恢复
mysql_increment_recovery() {
innobackupex --apply-log --redo-only $mysql_path/mysql-`date +%Y%m%d`/
innobackupex --apply-log --redo-only $mysql_path/mysql-`date +%Y%m%d`/ --incremental-dir=$mysql_path/mysql-`date +%Y%m%d`/
systemctl stop mysqld
mv /var/lib/mysql /var/lib/mysql2
innobackupex --defaults-file=/etc/my.cnf --copy-back $mysql_path/mysql-`date +%Y%m%d`/
chown -R mysql.mysql /var/lib/mysql
systemctl start mysqld
exit 0
}
man() {
mysql_backup
#mysql_recovery
mysql_increment
#mysql_increment_recovery
}
man
标签:增量备份 var pex file log nobackup default my.cnf bash
原文地址:https://blog.51cto.com/13399294/2386826