mysql xtarbackup备份脚本
#!/bin/sh # Backup db by evan at 20160927 # # Script config User="user" Password="passwd" Basedir=/application/mysql/bin Dump="$Basedir/mysqldump -u$User -p$Password" Backup_dir="/data/mysql/3306/backup" #database="test_db_v0_1" # Slave stop sql_thread $Basedir/mysql -u$User -p$Password -e "stop slave sql_thread;" # Backup [ ! -d $Backup_dir ] && /bin/mkdir -p $Backup_dir #$Dump -B -R -x --master-data=2 $database|gzip >$Backup_dir/$(date +%F -d -1day)_${database}.sql.gz 2>>${Backup_dir}_error.log /usr/bin/innobackupex --defaults-file=/etc/my.cnf --user=$User --password=$Password $Backup_dir 2>>$Backup_dir/`date +%F`_backup_error.log # Slave start sql_thread $Basedir/mysql -u$User -p$Password -e "start slave sql_thread;" # Clear Backup /usr/bin/find $Backup_dir -type d -mtime +7 -name "20*"|xargs /usr/bin/rm -fr