主要还是讲rsync的实践

上机实验

还有写一些脚本

下面是自动备份的脚本


#bak site and logs

ip= 'grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth0|cut -d = -f2'

mkdir    /backup/$ip -p


cd /var/html && tar zcf /backup/$ip/www_$(date +%F).tar.gz    ./www

cd /app && tar zcf /backup/$ip/logs_$(date +%F).tar.gz    ./logs


#bak sys conf

cd / && tar zcf /backup/$ip/etc_$(date +%F).tar.gz    ./etc

cd /server && tar zcf /backup/$ip/script_$(date    +%F).tar.gz ./scripts

/bin/cp    /var/spool/cron/root /backup/$ip/


#rsync data to bakserver

rsync -avzp /backup/ && rsync -avzp ./    rsync_backup@10.0.0.8::backup/$ip/    --password-file=/etc/

rsync.password> /dev/null 2>&1


#del data 7 days ago

find /backup -type f -name "*.tar.gz" -mtime +7|xargs rm -f