- #!/bin/bash
-
- ###mysql备份
- host=127.0.0.1
- user=bkpuser
- pwd=bkpuser
- dir=/home/mysql/XtraBackup
- log=backuplog.
date +%Y%m%d
- day=
date +%w
- dt=
date +%Y%m%d
- lastday=
date -d '1 days ago' +%Y%m%d
- case $day in
-
0)
复制 -
# Sunday Full backup
复制 -
# find $dir/ -name "xtra_*" -mtime +6 -exec rm -rf {} \;
复制 -
innobackupex --defaults-file=/etc/my.cnf --host=$host --user=$user --password=$pwd --no-timestamp $dir/xtra_base_$dt > $dir/log/$log 2>&1
复制 -
;;
复制 -
1)
复制 -
# Monday Relatively Sunday's incremental backup
复制 -
innobackupex --defaults-file=/etc/my.cnf --host=$host --user=$user --password=$pwd --no-timestamp --incremental $dir/xtra_inc_$dt --incremental-basedir=$dir/xtra_base_$lastday > $dir/log/$log 2>&1
复制 -
;;
复制 -
2)
复制 -
# Tuesday Compared with Monday's incremental backup
复制 -
innobackupex --defaults-file=/etc/my.cnf --host=$host --user=$user --password=$pwd --no-timestamp --incremental $dir/xtra_inc_$dt --incremental-basedir=$dir/xtra_inc_$lastday > $dir/log/$log 2>&1
复制 -
;;
复制 -
3)
复制 -
# Wednesday Full backup
复制 -
find $dir/ -name "xtra_*" -mtime +6 -exec rm -rf {} \;
复制 -
innobackupex --defaults-file=/etc/my.cnf --host=$host --user=$user --password=$pwd --no-timestamp $dir/xtra_base_$dt > $dir/log/$log 2>&1
复制 -
;;
复制 -
4)
复制 -
# Thursday Relatively Wednesday's incremental backup
复制 -
innobackupex --defaults-file=/etc/my.cnf --host=$host --user=$user --password=$pwd --no-timestamp --incremental $dir/xtra_inc_$dt --incremental-basedir=$dir/xtra_base_$lastday > $dir/log/$log 2>&1
复制 -
;;
复制 -
5)
复制 -
# Friday Compared with Thursday's incremental backup
复制 -
innobackupex --defaults-file=/etc/my.cnf --host=$host --user=$user --password=$pwd --no-timestamp --incremental $dir/xtra_inc_$dt --incremental-basedir=$dir/xtra_inc_$lastday > $dir/log/$log 2>&1
复制 -
;;
复制 -
6)
复制 -
# Saturday Compared with Friday's incremental backup
复制 -
innobackupex --defaults-file=/etc/my.cnf --host=$host --user=$user --password=$pwd --no-timestamp --incremental $dir/xtra_inc_$dt --incremental-basedir=$dir/xtra_inc_$lastday > $dir/log/$log 2>&1
复制 -
;;
复制 - esac
- find $dir/log/ -mtime +6 -type f -name ‘backuplog.*’ -exec rm -rf {} ;
最后修改时间:2023-08-24 11:07:28
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
【MySQL 30周年庆】MySQL 8.0 OCP考试限时免费!教你免费领考券
墨天轮小教习
3186次阅读
2025-04-25 18:53:11
MySQL 30 周年庆!MySQL 8.4 认证免费考!这次是认真的。。。
严少安
885次阅读
2025-04-25 15:30:58
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
527次阅读
2025-04-17 17:02:24
MySQL 9.3 正式 GA,我却大失所望,新特性亮点与隐忧并存?
JiekeXu
453次阅读
2025-04-15 23:49:58
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
381次阅读
2025-04-15 14:48:05
MySQL 8.0 OCP 1Z0-908 考试解析指南(二)
JiekeXu
339次阅读
2025-04-30 17:37:37
记录MySQL数据库的一些奇怪的迁移需求!
陈举超
298次阅读
2025-04-15 15:27:53
SQL优化 - explain查看SQL执行计划(下)
金同学
292次阅读
2025-05-06 14:40:00
MySQL 30 周年庆!MySQL 8.4 认证免费考!这次是认真的。。。
数据库运维之道
283次阅读
2025-04-28 11:01:25
MySQL 8.0 OCP 1Z0-908 考试题解析指南
青年数据库学习互助会
281次阅读
2025-04-30 12:17:54