进程服务企业应用"/>
Rsync守护进程服务企业应用
目录
一、 守护进程多模块功能配置
二、守护进程的排除功能实践
三、守护进程来创建备份目录
四、守护进程的访问控制配置
五、守护进程的列表功能配置
一、 守护进程多模块功能配置
sa sa_data.txt
dev dev_data.txt
dba dba_data.txt
第一步:
编辑配置文件
vim /etc/rsyncd.conf
[backup]
comment = "backup dir by yaobin"
path = /backup
[dba]
comment = "backup dir by yaobin"
path = /dba
[devdata]
comment = "backup dir by yaobin"
path = /devdata
第二步:
创建目录
mkdir /{dba,devdata}
第三部:
修改属主属组权限
chown rsync.rsync /{dba,devdata}
第四步:
重启服务
systemctl restart rsyncd
二、守护进程的排除功能实践
准备环境:
[root@nfs01 /]# mkdir -p /yaobin
[root@nfs01 /]# mkdir -p /yaobin/{a..c}
[root@nfs01 /]# touch /yaobin/{a..c}/{1..3}.txt
[root@nfs01 /]# tree /yaobin
/yaobin
├── 01.txt
├── 02.txt
├── a
│?? ├── 1.txt
│?? ├── 2.txt
│?? └── 3.txt
├── b
│?? ├── 1.txt
│?? ├── 2.txt
│?? └── 3.txt
└── c
├── 1.txt
├── 2.txt
└── 3.txt
需求01: 将/yaobin目录下面 a目录数据全部备份 b目录不要备份1.txt文件 c整个目录不要做备份
--exclude=PATTERN
绝对路径方式:
[root@nfs01 /]# rsync -avz /yaobin --exclude=/yaobin/b/1.txt --exclude=/yaobin/c/ rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password
sending incremental file list
yaobin/
yaobin/01.txt
yaobin/02.txt
yaobin/a/
yaobin/a/1.txt
yaobin/a/2.txt
yaobin/a/3.txt
yaobin/b/
yaobin/b/2.txt
yaobin/b/3.txt
相对路径方式:
[root@nfs01 /]# rsync -avz /yaobin --exclude=b/1.txt --exclude=c/ rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password
sending incremental file list
yaobin/
yaobin/01.txt
yaobin/02.txt
yaobin/a/
yaobin/a/1.txt
yaobin/a/2.txt
yaobin/a/3.txt
yaobin/b/
yaobin/b/2.txt
yaobin/b/3.txt
sent 502 bytes received 177 bytes 1,358.00 bytes/sec
total size is 0 speedup is 0.00
需求02: 将/yaobin目录下面 a目录数据全部备份 b目录不要备份1.txt文件 c整个目录1.txt 3.txt文件不要备份
--exclude-from=file --- 批量排除
第一个历程: 编辑好一个排除文件
[root@nfs01 /]# cat /yaobin/exclude.txt
b/1.txt
c/1.txt
c/3.txt
exclude.txt
第二个历程: 实现批量排除功能
[root@nfs01 /]# rsync -avz /yaobin --exclude-from=/yaobin/exclude.txt rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password
sending incremental file list
yaobin/
yaobin/01.txt
yaobin/02.txt
yaobin/a/
yaobin/a/1.txt
yaobin/a/2.txt
yaobin/a/3.txt
yaobin/b/
yaobin/b/2.txt
yaobin/b/3.txt
yaobin/c/
yaobin/c/2.txt
三、守护进程来创建备份目录
[root@nfs01 /]# rsync -avz /etc/hosts rsync_backup@172.16.1.41::backup/10.0.0.31/ --password-file=/etc/rsync.password
sending incremental file list
created directory 10.0.0.31
hosts
sent 226 bytes received 75 bytes 602.00 bytes/sec
total size is 371 speedup is 1.23
PS: 客户端无法在服务端创建多级目录
四、守护进程的访问控制配置
守护进程白名单和黑名单功能
PS: 建议只使用一种名单
五、守护进程的列表功能配置
[root@nfs01 /]# rsync rsync_backup@172.16.1.41::
backup "backup dir by yaobin"
dba "backup dir by yaobin"
dev "backup dir by yaobin"
更多推荐
Rsync守护进程服务企业应用
发布评论