Rsync文件同步实录

Rsync服务的搭建和使用

下载编译安装:

第一步:修改rsyncd的配置文件,增加测试目录test

第二步:修改rsync密码文件,添加pic_test模块的用户和密码

root@localhost:/data/sa

第三步:重启rsyncd服务

命令同步示例:

从rsync服务器同步test_code模块文件到本地,除/home/huangjie1/pass_id.list目录以外的文件:

同步文件时备份参数的使用示例:

1)同步文件,直接加参数-b,会在目标主机的模块目录下备份文件:1.txt~

扩展:

一般和sersync,lrsync,inotify-tools等工具实现自动发现实时同步文件或者双向同步,各有优缺点,可自行查阅资料了解。

lsync配置实例:

settings {
logfile = "/var/log/lsyncd_to_sites_bak.log",
nodaemon = true,
statusInterval = 10,
inotifyMode = "CloseWrite or Modify",
maxProcesses = 10
}

sync {
default.rsync,
source = "/usr/local/nginx/conf/sites/",
target = "sites@ip1::sites",
-- or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
excludeFrom = "/etc/lsyncd/exclude.conf",
delete = true,
rsync = {
archive = true,
compress = true,
_extra = {"--password-file=/etc/lsyncd/rsyncd_to_sites.passwd","--port=873","--numeric-ids", "--bwlimit=10000"},
}

}
sync {
default.rsync,
source = "/usr/local/nginx/conf/sites/",
target = "sites@ip2::sites",
-- or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
excludeFrom = "/etc/lsyncd/exclude.conf",
delete = true,
rsync = {
archive = true,
compress = true,
_extra = {"--password-file=/etc/lsyncd/rsyncd_to_sites.passwd","--port=873","--numeric-ids", "--bwlimit=10000"},
}

}

启动:

lsyncd --nodaemon /etc/lsyncd/lsyncd_to_sites.conf &

声明:文中观点不代表本站立场。本文传送门:https://eyangzhen.com/235140.html

联系我们
联系我们
分享本页
返回顶部