Linux服务器:
=====================================================
1. 安装软件
1
2
3
4
5
|
[root@localhost ~]# yum -y install rsync
[root@localhost ~]# cd /etc/sysconfig
[root@localhost ~]# vi iptables
#增加: -A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT
[root@localhost ~]# service iptables restart
|
2. 配置rsync
1
2
|
# touch /etc/rsyncd.conf
# vi /etc/rsyncd.conf
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
secrets file = /etc/rsyncd.server
read only = yes
list = yes
uid = nobody
gid = nobody
hosts allow = 192.168.0.91
use chroot = no
max connections = 100
transfer logging = yes
log format = %t %a %m %f %b
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
[rsyncd]
comment = my rsync server
path = /tmp/test
auth users = root
secrets file = /etc/rsyncd.server
|
3. 权限配置创建账户文件
1
2
3
|
# echo root:root > /etc/rsyncd.server
# chown root:root /etc/rsyncd.server
# chmod 600 /etc/rsyncd.server
|
4. 创建文件夹:
1
2
3
|
# mkdir /tmp/test
# cd /tmp/test
# touch a.txt
|
最后在server端将rsync以守护进程形式启动
命令为:
1
|
rsync --daemon --config /etc/rsyncd.conf
|
rsync启动的端口为 873端口
最好用ntsysv或者chkconfig将rsync设置为开机自动启动
window客户机:
=====================================================
1, 安装cwRsync工具,cwRsync_4.1.0_Installer.exe; 拷贝服务端cwRsyncServer_4.1.0_ICW(版本跟上面一致,已经安装后复制备份的文件夹了)的chown.exe 到安装目录的 bin目录中去。
2. 建立认证的密码文件在E:\rsyncd.client , 内容是上面的设置的密码:root. 然后执行:
1
2
|
# chmod -c 600 /cygdrive/e/rsyncd.client
# chown administrator /cygdrive/e/rsyncd.client
|
3. 建立要备份到本地的目录如: E:\rsync
4.环境变量path追加: C:\Program Files\cwRsync\bin在最前面
测试:
在window客户机执行:
1
2
3
4
5
6
7
8
9
10
11
12
|
rsync -vzrtopg --progress --delete --password-file=/cygdrive/e/rsyncd.client root@192.168.0.55::rsyncd /cygdrive/e/rsync
输出:
C:\Documents and Settings\Administrator>rsync -vzrtopg --progress --delete --pas
sword-file=/cygdrive/e/rsyncd.client root@192.168.0.55::rsyncd /cygdrive/e/rsync
receiving incremental file list
./
a.txt
0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/2)
sent 78 bytes received 147 bytes 450.00 bytes/sec
total size is 0 speedup is 0.00
|
重要:
chmod -c 600 /cygdrive/e/pass.txt
这篇文章还没有评论