- #!/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进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




