標籤:線上backup
650) this.width=650;" title="backup伺服器.jpg" alt="wKioL1UeKPDxOxG1AAD_i46AoDA854.jpg" src="http://s3.51cto.com/wyfs02/M00/5C/97/wKioL1UeKPDxOxG1AAD_i46AoDA854.jpg" />
[[email protected] 192.168.1.20]# cat /server/scripts/beifen.sh
#!/bin/sh
IP=$(ifconfig |awk -F ‘[ :]+‘ ‘NR==2 {print $4}‘)
Path="/backup/$IP"
[ ! -d $Path ] && mkdir $Path -p
MUBIAO="/app"
#backup
tar zcf $Path/www_$(date +%F).tar.gz /application/httpd &&\
tar zcf $Path/conf_$(date +%F).tar.gz /var/spool/cron/root /etc/rc.local /etc/sysconfig/iptables /server/scripts &&\
tar zcf $Path/logs_$(date +%F).tar.gz $MUBIAO &&\
find /backup/ -type f -name "*$(date +%F).tar.gz"|xargs md5sum >>$Path/flag_$(date +%F)
#to bak server
rsync -avz /backup/ [email protected]::backup --password-file=/etc/rsync.password
#del
find /backup/ -type f -name "*.tar.gz" -mtime +7 | xargs rm -f
[[email protected] scripts]# cd /backup/
[[email protected] backup]# ls
192.168.1.20
[[email protected] backup]# cd 192.168.1.20/
[[email protected] 192.168.1.20]# ls
conf_2015-04-03.tar.gz flag_2015-04-03 logs_2015-04-03.tar.gz www_2015-04-03.tar.gz
[[email protected] 192.168.1.20]# md5sum -c flag_2015-04-03
/backup/192.168.1.20/www_2015-04-03.tar.gz: OK
/backup/192.168.1.20/logs_2015-04-03.tar.gz: OK
/backup/192.168.1.20/conf_2015-04-03.tar.gz: OK
本文出自 “晴空” 部落格,謝絕轉載!
線上業務備份+定期刪除備份檔案+MD5加密