rsync daemonバックアップサーバの構築
rsync daemonバックアップサーバの構築
[root@NFS-server ~]# rpm -qa rsync rsync-3.0.6-12.el6.x86_64[root@NFS-server ~]# touch /etc/rsyncd.conf
[root@NFS-server ~]# 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
[root@NFS-server ~]# mkdir /backup [root@NFS-server ~]# useradd rsync
[root@NFS-server ~]# id rsync uid=500(rsync) gid=500(rsync) groups=500(rsync) [root@NFS-server ~]# chown -R rsync /backup/ [root@NFS-server ~]# ls /backup/ [root@NFS-server ~]# ll /backup/ total 0 [root@NFS-server ~]# ls -ld /backup/ drwxr-xr-x. 2 rsync root 4096 Jul 5 22:00 /backup/
[root@NFS-server ~]# echo "rsync_backup:oldboy" >>/etc/rsync.password [root@NFS-server ~]# chmod 600 /etc/rsync.password [root@NFS-server ~]# ll /etc/rsync.password -rw-------. 1 root root 20 Jul 5 22:02 /etc/rsync.password [root@NFS-server ~]# cat /etc/rsync.password rsync_backup:oldboy
[root@NFS-server ~]# rsync --daemon [root@NFS-server ~]#
[root@NFS-server ~]# 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日間のデータが保持されますが、金曜日のデータは永続的に保持されます.
[root@NFS-server ~]# 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
[root@NFS-server ~]# /bin/sh /server/scripts/reserve.sh [root@NFS-server ~]# 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
[root@NFS-server ~]# 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