ITPub博客

首页 > 数据库 > MySQL > innobackuppex全备脚本

innobackuppex全备脚本

原创 MySQL 作者:生活怪盗 时间:2017-07-18 16:26:08 0 删除 编辑
[root@localhost ~]# vi backup_full.bk
#!/bin/bash  
mysql_backup_dir=/data/backup/
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
echo `date` "------------------------------end full_backup" >> /data/backup/$logfile

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25911813/viewspace-2142251/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2016-11-14

  • 博文量
    19
  • 访问量
    17005