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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
daemon端配置: 创建配置文件 [root@Backup-server ~] # touch /etc/rsyncd.conf [root@Backup-server ~] # vi /etc/rsyncd.conf [root@Backup-server ~] # cat /etc/rsyncd.conf #rsync server #created by lufeng@3.15 ##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 lufeng@3.15 ##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 创建用户及共享目录 [root@Backup-server ~] # useradd rsync -s /sbin/nologin -M [root@Backup-server ~] # mkdir /backup [root@Backup-server ~] # chown -R rsync /backup/ 创建密码文件 [root@Backup-server ~] # echo "rsync_backup:199429" >/etc/rsync.password [root@Backup-server ~] # cat /etc/rsync.password rsync_backup:199429 [root@Backup-server ~] # chmod 600 /etc/rsync.password 启动 rsync 及查看端口 [root@Backup-server ~] # rsync --daemon [root@Backup-server ~] # ps -ef|grep rsync|grep -v grep [root@Backup-server ~] # netstat -lntup|grep rsync [root@Backup-server ~] # lsof -i :873 设置开机启动 [root@Backup-server ~] # echo "rsync --deamon" >>/etc/rc.local [root@Backup-server ~] # cat /etc/rc.local 客户端配置: 创建密码文件 [root@lnmp01 ~] # echo "199429" >/etc/rsync.password [root@lnmp01 ~] # chmod 600 /etc/rsync.password [root@lnmp01 ~] # cat /etc/rsync.password 199429 推送备份 rsync push: [root@lnmp01 ~] # rsync -avz /tmp/ rsync_backup@192.1.1.7::backup --password-file=/etc/rsync.password 增量备份成功,结合定时任务实现定时备份。 |
本文出自 “大梦初醒” 博客,请务必保留此出处http://bestlufeng.blog.51cto.com/11790256/1907052