小知识:rsync 数据同步使用详解

rsync

(d)服务端启动两种方式

1.daemon 2.xinetd inetd

启动后绑在 TCP/873 端口

% 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

socket_type = stream

wait = no

user = root

server = /usr/bin/rsync

server_args = —daemon

log_on_failure += USERID

}

配置 注意设置读写权限属主

% cat /etc/rsyncd.conf

motd file = /var/log/rsync/welcome.msg

pid file = /var/log/rsync/rsyncd.pid

lock file = /var/log/rsync/rsync.lock

log file = /var/log/rsync/rsyncd.log

[rsyncwww]

comment = rsync www

path = /var/www/

use chroot = no

max connections = 4

read only = false

list = true

uid = nobody

gid = nobody

auth users = wwwuser

secrets file = /etc/rsyncd.secrets

hosts allow = 1.1.1.1,2.2.2.2

hosts deny = 0.0.0.0/0

ignore errors = yes

transfer logging = yes

log format = “%a %f %l”

#log format = “%o %h [%a] %m (%u) %f %l”

[rsyncroot]

comment = rsync root

path = /

use chroot = no

max connections = 4

read only = true

#read only = false

list = true

uid = root

gid = root

auth users = rootuser

secrets file = /etc/rsyncd.secrets

hosts allow = 1.1.1.1,2.2.2.2

hosts deny = 0.0.0.0/0

ignore errors = yes

transfer logging = yes

log format = “%a %f %l”

rsyncd.secrets 一行一个用户 用户名:密码 格式

使用

rsync -auvPz –progress dir1 dir2

rsync -ztruvoglpD –progress dir1 dir2

rsync -ztruvoglpD –progress dir1/ dir2

rsync -ztruvoglpD –progress dir1/file1 dir2

如果不想包含某个目录/文件可以设置–exclude

远程使用

rsync 1.1.1.1:: 只列list

rsync user@1.1.1.1::

rsync user@1.1.1.1::module

rsync user@1.1.1.1::module/path

如果没有配置rsync server 可以通过 ssh 方式使用

rsync -e ssh -auvPz 1.1.1.1:/etc ./

同步时注意注意 / 最后的问题

不放/ 则目录名也包含mirror

放 / 则只有目录里面的东西mirror了

rsync -ztruvoglp –progress user@1.1.1.1::module/path ./

为了脚本调用方便 还可以调用 –password-file 同样注意属主权限

也可以设置环境变量RSYNC_PASSWORD=访问含用户认证的rsync
声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。
建站知识

小知识:eclipse3.2.2 + MyEclipse5.5 + Tomcat5.5.27 配置数据库连接池

2023-4-23 11:44:19

建站知识

小知识:Apache服务器二级域名的完美实现

2023-4-23 11:58:40

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索