背景:
阅读新闻
Debian 使用Unison双向同步文件
[日期:2012-02-14] 来源:Linux社区 作者:stuhack [字体:]
Debian6.0 squeeze
Server1:192.168.1.104
Server2:192.168.1.105
安装之前需要Server1与Server2之间SSH互相信任 请参考以下文章:
Server1
#vi /etc/apt/sources.list
deb squeeze main non-free contrib
deb squeeze-proposed-updates main contrib non-free
deb squeeze/updates main contrib non-free
deb-src squeeze main non-free contrib
deb-src squeeze-proposed-updates main contrib non-free
deb-src squeeze/updates main contrib non-free
deb squeeze main contrib non-free
deb squeeze/non-US main contrib non-free
deb squeeze/updates main contrib non-free
#apt-get update
#apt-get install unison //两台Server都需要安装unison
#usr/bin/unison
#vi /root/.unison/default.prf
root = /root/test/
root = ssh://192.168.1.105//root/test/
#force =/root/test/
# Paths to synchronize
#path = bbs/attachments
#path = uc/data/avatar
#path = uchome/attachment
# Some regexps specifying names and paths to ignore
#ignore = Path bbs/attachments/swfupload
#ignore = Name temp.*
#ignore = Name *~
#ignore = Name .*~
#ignore = Name *.mp3
auto = true
batch = true
maxthreads = 500
owner = true
group = true
perms = -1
repeat = 1
retry = 3
sshargs = -C
xferbycopying = true
silent = true
fastcheck = true
log = true
logfile = /root/.unison/unixidc_122.1547.log
Server1创建/root/test
#mkdir /root/test
Server2创建/root/test
#mkdir /root/test
#/usr/bin/unison&
推送到后台安静模式运行
如果Server1的/root/test想同步到Server2的/root/test2
需要在Server1创建/root/test Server2创建/root/test2
配置文件为 root = ssh://192.168.1.105//root/test2/
其中要注意的是:
1.force去掉前面的# 那就是Server1单向同步到Server2
2.silent = true 是以安静模式运行 否则一直会有以下提示
root@localhost:~# /usr/bin/unison
Contacting server…
Connected [//localhost//root/test -> //unixidc//root/test]
Looking for changes
Waiting for changes from server
Reconciling changes
Nothing to do: replicas have not changed since last sync.
Sleeping for 1 seconds…
Looking for changes
Waiting for changes from server
Reconciling changes
Nothing to do: replicas have not changed since last sync.
3.path 是指定你需要同步的目录,用ignore指定path中需要排除的目录及文件
4.要双向同步的目录都不允许为空 否则unison进程会自动结束 并提示Aborting…
Linux配置双机SSH信认并用public key认证登录
相关资讯
本文评论 查看全部评论 (0)
尊重网上道德,遵守中华人民共和国的各项有关法律法规 承担一切因您的行为而直接或间接导致的民事或刑事法律责任 本站管理人员有权保留或删除其管辖留言中的任意内容 本站有权在网站内转载或引用您的评论 参与本评论即表明您已经阅读并接受上述条款
评论声明
最新资讯