暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

innobackupex-mysql备份-全备和增量

原创 ONE 2020-09-18
862
  1. #!/bin/bash
  2. ###mysql备份
  3. host=127.0.0.1
  4. user=bkpuser
  5. pwd=bkpuser
  6. dir=/home/mysql/XtraBackup
  7. log=backuplog.date +%Y%m%d
  8. day=date +%w
  9. dt=date +%Y%m%d
  10. lastday=date -d '1 days ago' +%Y%m%d
  11. case $day in
  12. 0)  
    
    复制
  13.     # Sunday Full backup
    
    复制
  14.     # find $dir/ -name "xtra_*" -mtime +6 -exec rm -rf {} \;
    
    复制
  15.     innobackupex --defaults-file=/etc/my.cnf  --host=$host --user=$user --password=$pwd --no-timestamp $dir/xtra_base_$dt > $dir/log/$log 2>&1
    
    复制
  16.     ;;  
    
    复制
  17. 1)  
    
    复制
  18.     # Monday Relatively Sunday's incremental backup  
    
    复制
  19.     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  
    
    复制
  20.     ;;  
    
    复制
  21. 2)  
    
    复制
  22.     # Tuesday Compared with Monday's incremental backup  
    
    复制
  23.     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     
    
    复制
  24.     ;;  
    
    复制
  25. 3)  
    
    复制
  26.     # Wednesday Full backup
    
    复制
  27.     find $dir/ -name "xtra_*" -mtime +6 -exec rm -rf {} \;
    
    复制
  28.     innobackupex --defaults-file=/etc/my.cnf  --host=$host --user=$user --password=$pwd --no-timestamp $dir/xtra_base_$dt > $dir/log/$log 2>&1   
    
    复制
  29.     ;;  
    
    复制
  30. 4)  
    
    复制
  31.     # Thursday  Relatively Wednesday's incremental backup  
    
    复制
  32.     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    
    
    复制
  33.     ;;  
    
    复制
  34. 5)  
    
    复制
  35.     # Friday Compared with Thursday's incremental backup  
    
    复制
  36.     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    
    
    复制
  37.     ;;  
    
    复制
  38. 6)  
    
    复制
  39.     # Saturday Compared with Friday's incremental backup  
    
    复制
  40.     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   
    
    复制
  41.     ;;  
    
    复制
  42. esac
  43. find $dir/log/ -mtime +6 -type f -name ‘backuplog.*’ -exec rm -rf {} ;
最后修改时间:2023-08-24 11:07:28
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论