服务端配置:
(放主要数据的机器)
/etc/rsyncd/rsyncd.conf
---------------------------------------------
##### global settings
# 匿名用户设置
uid=nobody
gid=nobody
use chroot=no
# 最大连接数
max connections=4
pid file=/var/run/rsyncd.pid
# 日志
log format = %t %a %m %f %b
log file=/var/log/rsyncd.log
# 限制访问的 IP
hosts allow=192.168.1.0/255.255.255.0 10.0.0.1/255.0.0.0
hosts deny=*
#This will log every file transferred - up to 85,000+ per user, per sync
#transfer logging = yes
# IP 超时时间
timeout=500
##### 设置模块:本机要同步的目录
[rsync-test]
path=/home/cdy/rsync-test
comment= This is rsync server
# 客户端只读
read only=yes
#
list=yes
# 排除目录
#exclude=nmap-5.00/ ssh/
# 忽略错误
ignore errors
# 用于用户验证
#auth users=cdy
#secrets file=/etc/rsyncd/rsyncd.secrets
-------------------------------------------------------
rsync --daemon --config=/etc/rsyncd/rsyncd.conf
(默认端口:873, 可以指定端口) --port=57777
客户端:
(备份数据机器)
---------------------
列出服务器上的同步资源
rsync --list-only 192.168.1.214::
执行命令(匿名方式)
crontab -e
*/1 * * * * /usr/bin/rsync -zqrtopg --delete 192.168.1.214::rsync-test /home/cdy/backup/
(如果不用默认端口,使用--port=57777)
部分参数:
rsync-test:服务器上定义的同步模块名称
-z 压缩传递
-r 递归
-q 安静模式
-topg 保留原文件的属性
--delete 如果服务端删除了文件,则客户端也删除
...
---------------------
==============
上传同步(把本地东东上传到服务器)
rsync -vzrtopg --progress ./get/ root@xxx.xxx.xxx.xxx::backup
================
阅读(432) | 评论(0) | 转发(0) |