搭建rsync daemon 备份服务器
[[email protected] ~]# rpm -qa rsync
rsync-3.0.6-12.el6.x86_64
[[email protected] ~]# touch /etc/rsyncd.conf
[[email protected] ~]# vim /etc/rsyncd.conf
#created by yvonne 2015-7-5 21:59:55 ##rsyncd.conf start## uid = rsync gid = rsync use chroot = no max connections = 2000 timeout = 600 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log ignore errors read only = false list = false hosts allow = 192.168.10.0/24 hosts deny = 0.0.0.0/32 auth users = rsync_backup secrets file = /etc/rsync.password ##################################### [backup] comment = backup server by yvonne 2015-7-5 22:00:06 path = /backup "/etc/rsyncd.conf" 22L, 696C written
[[email protected] ~]# mkdir /backup
[[email protected] ~]# useradd rsync
[[email protected] ~]# id rsync
uid=500(rsync) gid=500(rsync) groups=500(rsync)
[[email protected] ~]# chown -R rsync /backup/
[[email protected] ~]# ls /backup/
[[email protected] ~]# ll /backup/
total 0
[[email protected] ~]# ls -ld /backup/
drwxr-xr-x. 2 rsync root 4096 Jul 5 22:00 /backup/
[[email protected] ~]# echo "rsync_backup:oldboy" >>/etc/rsync.password
[[email protected] ~]# chmod 600 /etc/rsync.password
[[email protected] ~]# ll /etc/rsync.password
-rw-------. 1 root root 20 Jul 5 22:02 /etc/rsync.password
[r[email protected] ~]# cat /etc/rsync.password
rsync_backup:oldboy
[[email protected] ~]# rsync --daemon
[[email protected] ~]#
[[email protected] ~]# vim /etc/rc.local
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don‘t # want to do the full Sys V style init stuff. touch /var/lock/subsys/local /etc/init.d/iptables stop rsync --daemon
备份服务器上保留180天的数据,但周五数据永久保留:
[[email protected] ~]# vim /server/scripts/reserve.sh
#!/bin/sh #print for reserve backup files 180 days by yvonne 2015-7-5 23:38:34. find /backup/data/ -type f -mtime +180 -name "*.tar.gz" |xargs rm -rf
[[email protected] ~]# /bin/sh /server/scripts/reserve.sh
[[email protected] ~]# crontab -e
#print for reserve backup files 180 days by yvonne 2015-7-5 23:38:34.
00 05 * * * /bin/sh /server/scripts/reserve.sh >/dev/null 2&>1
[[email protected] ~]# crontab -l
#print for ntpdate by yvonne 2015-7-5 09:46:20.
*/5 * * * * /bin/sh /server/scripts/ntpdate.sh >/dev/null 2>&1
#print for reserve backup files 180 days by yvonne 2015-7-5 23:38:34.
00 05 * * * /bin/sh /server/scripts/reserve.sh >/dev/null 2&>1