rsync增量备份脚本

shell脚本:

#!/bin/bash

export PATH=/usr/local/bin:/usr/bin:/bin

dir=/mnt/
DAY=`date "+%Y-%m-%d" `

DAY2=`date --date='7 days ago' +%Y-%m-%d`
    
if [  -d $dir$DAY2 ];then 
  rm  -rf $dir$DAY2  
fi

rsync -az --delete /opt/nginx  /mnt/$DAY

 

加入到crontab,每2小时执行一次

0 */2 * * *  /bin/bash   /mnt/nginx_bak.sh  > /mnt/nginx_log.log 2>&1

猜你喜欢

转载自www.cnblogs.com/heruiguo/p/9268664.html