目录

rsync server/client配置

服务端

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
mkdir /etc/rsyncd

vi /etc/rsyncd/rsyncd.conf

uid = root
gid = root
hosts allow = *
use chroot = yes
max connections = 10
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
logf ile = /var/log/rsyncd.log
timeout = 600
port = 873

[sh1]
path = /data1
read only = yes
comment = Rsync File
write only = no
list = no
auth users = rsync
secrets file = /etc/.rsyncd.secrets

[sz1]
path = /data2
read only = yes
comment = Rsync File
write only = no
list = no
auth users = rsync
secrets file = /etc/.rsyncd.secrets
  

vi /etc/.rsyncd.secrets

rsync:passwd
  

cat /etc/xinetd.d/rsync

# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#	allows crc checksumming etc.
service rsync
{
 disable	= no
 flags	= IPv6
 socket_type = stream
 wait = no
 user = root
 #server = /usr/local/bin/rsync
 server = /usr/bin/rsync
 server_args = --daemon --config=/etc/rsyncd/rsyncd.conf
 log_on_failure += USERID
}
 

/etc/init.d/xinetd restart

客户端

密码

1
2
cat /etc/.rsyncd.secrets
passwd

上传

rsync -vzrtopg --delete --progress test.sh rsync@192.168.2.221::sh1 --password-file=/etc/.rsyncd.secrets

下载

rsync -vzrtopg --delete --progress rsync@192.168.2.221::sh1 /data --password-file=/etc/.rsyncd.secrets

常用rsync命令

将目标机器的数据同步到本机

rsync -vrzt 192.168.1.109:/www/users/mulinux.com/ ./

将本机的数据同步到目标机器

1
2
3
4
rsync -avz -e "ssh -p 22" ./ root@:/www/users/
a 以archive模式操作、复制目录、符号连接 相当于-rlptgoD
v 详细模式输出
z 对备份文件在传输时进行压缩处理