[root@localhost ~]# vi backup_full.bk
#!/bin/bash
mysql_backup_dir=/data/backup/
mysql_username="root"
mysql_password=" "
mysql_username="root"
mysql_password=" "
cd $mysql_backup_dir
lastincrementfolder=`ls -l|grep ^d|tail -n 1 | awk '{print $9}'`
timeStart=$(date '+%Y%m%d%H%M%S')
logfile=full-$timeStart.log
/xtrabackup/bin/innobackupex --defaults-file=/etc/my.cnf --user=$mysql_username $mysql_backup_dir >> "$logfile" 2>&1
latestfolder=`ls -l|grep ^d|tail -n 1 | awk '{print $9}'`
tar -czvf /data/backup/full_$latestfolder.tar.gz /data/backup/$latestfolder --remove-files >> "$logfile" 2>&1
find /data/backup -mtime +7 |xargs rm -rf >> "$logfile" 2>&1
lastincrementfolder=`ls -l|grep ^d|tail -n 1 | awk '{print $9}'`
timeStart=$(date '+%Y%m%d%H%M%S')
logfile=full-$timeStart.log
/xtrabackup/bin/innobackupex --defaults-file=/etc/my.cnf --user=$mysql_username $mysql_backup_dir >> "$logfile" 2>&1
latestfolder=`ls -l|grep ^d|tail -n 1 | awk '{print $9}'`
tar -czvf /data/backup/full_$latestfolder.tar.gz /data/backup/$latestfolder --remove-files >> "$logfile" 2>&1
find /data/backup -mtime +7 |xargs rm -rf >> "$logfile" 2>&1
echo `date` "------------------------------end full_backup" >> /data/backup/$logfile
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25911813/viewspace-2142251/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25911813/viewspace-2142251/