daemon端配置: 创建配置文件 [[email protected] ~]# touch /etc/rsyncd.conf [[email protected] ~]# vi /etc/rsyncd.conf [[email protected] ~]# cat /etc/rsyncd.conf #rsync server #created by oldboy 15:01 2009-6-5 ##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.1.1.0/24 hosts deny = 0.0.0.0/32 ====》不拒绝ip地址 auth users = rsync_backup secrets file = /etc/rsync.password ====》存放用户和密码的文件 ##################################### [backup] ====》共享模块 comment = Backup server by lufeng 3.15 =====》注释 path = /backup ====》共享目录 可粘贴部分 #rsync server #created by oldboy 15:01 2009-6-5 ##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.1.1.0/24 hosts deny = 0.0.0.0/32 auth users = rsync_backup secrets file = /etc/rsync.password ##################################### [backup] comment = www by lufeng path = /backup 创建用户及共享目录 [[email protected] ~]# useradd rsync -s /sbin/nologin -M [[email protected] ~]# mkdir /backup [[email protected] ~]# chown -R rsync /backup/ 创建密码文件 [[email protected] ~]# echo "rsync_backup:199429" >/etc/rsync.password [[email protected] ~]# cat /etc/rsync.password rsync_backup:199429 [[email protected] ~]# chmod 600 /etc/rsync.password 启动rsync及查看端口 [[email protected] ~]# rsync --daemon [[email protected] ~]# ps -ef|grep rsync|grep -v grep [[email protected] ~]# netstat -lntup|grep rsync [[email protected] ~]# lsof -i :873 设置开机启动 [[email protected] ~]# echo "rsync --deamon" >>/etc/rc.local [[email protected] ~]# cat /etc/rc.local 客户端配置: 创建密码文件 [[email protected] ~]# echo "199429" >/etc/rsync.password [[email protected] ~]# chmod 600 /etc/rsync.password [[email protected] ~]# cat /etc/rsync.password 199429 推送备份rsync push: [[email protected] ~]# rsync -avz /tmp/ [email protected]::backup --password-file=/etc/rsync.password 增量备份成功,结合定时任务实现定时备份。
时间: 2024-12-28 17:25:42