标签:rsync cron
[root@www ~]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.8 (Final)
Release: 5.8
Codename: Final
正式环境需要修改IPTABLES
http://pan.baidu.com/s/1kT1du7P 下载地址
wget ftp://ftp.samba.org/pub/rsync/rsync-3.1.1.tar.gz
tar zxf rsync-3.1.1.tar.gz
cd rsync-3.1.1
./configure && make && make install
/usr/local/bin/rsync --daemon #或增加--config=/etc/rsyncd.conf
#rsyncd.conf、rsyncd.secrets、rsyncd.motd 默认无此文件,需要要创建,如下
[root@www etc]# cat rsyncd.secrets
rsync:rsync_password
[root@www etc]# cat rsyncd.conf
secrets file = /etc/rsyncd.secrets #认证用户密码文件,配置auth users的密码
motd file = /etc/rsyncd.motd #说明信息
read only = yes #只读,不能上传
list = yes #允许查看文件列表
uid = root #运行rsync守护进程用户
gid = root #运行rsync守护进程的组
use chroot = no #不使用chroot
max connections = 5 #最大连接数是5
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
#ignore errors #忽略无关的IO错误
#slp refresh = 300
[rsync]
comment = rsync‘s directory
path = /data/rsync
auth users = rsync #认证的用户名
hosts allow = 192.168.2.109 #允许访问服务的IP
#hosts deny = 0.0.0.0/32 #禁止访问服务器的IP
[root@www etc]# cat rsyncd.secrets
rsync:rsync_password
[root@www ~]# chmod 600 /etc/rsyncd.secrets
[root@www ~]# cat /etc/rsyncd.motd
Welcome to use the rsync services!
同步服务器配置
[root@www ~]# cat /etc/rsyncd.pass
rsync_password
[root@www ~]# chhmod 600 /etc/rsyncd.pass
[root@www ~]# rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.pass rsync@192.168.2.110::rsync /data/rsync/
receiving incremental file list
./
lzo-2.08.tar.gz
589,045 100% 33.04MB/s 0:00:00 (xfr#1, to-chk=1/4)
rsync-3.1.1.tar.gz
890,124 100% 24.25MB/s 0:00:00 (xfr#2, to-chk=0/4)
sent 65 bytes received 1,479,974 bytes 72,197.02 bytes/sec
total size is 1,479,182 speedup is 1.00
计划任务cron使用:
[root@www ~]# crontab -e
*/5 * * * * /usr/local/bin/rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.pass rsync@192.168.2.110::rsync /data/rsync/
常见报错:
ERROR: password file must not be other-accessible
rsync error: syntax or usage error (code 1) at authenticate.c(196) [Receiver=3.1.1]
解决:[root@www ~]# chmod 600 /etc/rsyncd.pass
@ERROR: auth failed on module rsync
rsync error: error starting client-server protocol (code 5) at main.c(1635) [Receiver=3.1.1]
解决:服务端未设置用户rsync
本文出自 “林子” 博客,谢绝转载!
标签:rsync cron
原文地址:http://1606496.blog.51cto.com/1596496/1565338