一、Rsync常用参数
1.常用参数
-a
-v
-z
-r
-t
-o
-p
-g
-l
-P
-D
-L
-e
--exclude=1.txt
--exclude-from=file
--bwlimit=100
--partial
--delete
--password-file=xxx
2.常用参数详解
[root@web01 ~]
[root@web01 ~]
总用量 12
-rw-r--r-- 1 root root 0 4月 28 07:29 10.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 1.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 2.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 3.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 4.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 5.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 6.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 7.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 8.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 9.txt
[root@web01 ~]
1.txt
2.txt
3.txt
[root@web01 ~]
=a.txt
[root@web01 opt]
记录了1000+0 的读入
记录了1000+0 的写出
1048576000字节(1.0 GB)已复制,6.9373 秒,151 MB/秒
[root@web01 opt]
1.txt
114,130,944 10% 1.01MB/s 0:15:06
[root@web01 opt]
[root@web01 opt]
总用量 4
-rw-r--r-- 1 root root 0 4月 28 07:29 10.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 4.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 5.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 6.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 7.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 8.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 9.txt
-rw-r--r-- 1 root root 18 4月 28 07:31 a.txt
[root@web01 opt]
[root@backup backup]
总用量 4
-rw-r--r-- 1 root root 0 4月 28 07:29 10.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 4.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 5.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 6.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 7.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 8.txt
-rw-r--r-- 1 root root 0 4月 28 07:29 9.txt
-rw-r--r-- 1 root root 18 4月 28 07:31 a.txt
拉取时:客户端数据与服务端数据一致,以服务端数据为准
推送时:服务端数据一客户端数据一致,以客户端数据为准
二、Rsync备份案例
1.准备服务器

2.了解需求
- 客户端需求:
客户端提前准备存放的备份的目录,目录规则如下:/backup/nfs_172.16.1.31_2018-09-02
客户端在本地打包备份(系统配置文件、应用配置等)拷贝至/backup/nfs_172.16.1.31_2018-09-02
客户端最后将备份的数据进行推送至备份服务器
客户端每天凌晨1点定时执行该脚本
客户端服务器本地保留最近7天的数据, 避免浪费磁盘空间
- 服务端需求:
服务端部署rsync,用于接收客户端推送过来的备份数据
服务端需要每天校验客户端推送过来的数据是否完整
服务端需要每天校验的结果通知给管理员
服务端仅保留6个月的备份数据,其余的全部删除
3.客户端操作
[root@web01 ~]
[root@web01 ~]