unsion使用

来源:互联网 发布:天勤网络 编辑:程序博客网 时间:2024/06/05 03:43
1:本地使用
使用方法:
#unison  aa bb  #同步本地的aa和bb文件夹(双向同步)


2: unison远程使用
使用方法:
#unison <本地目录> ssh://remotehostname(IP)/<远程目录的绝对路径>
#例:unison test1 ssh://cdn1//home/jianwei.ji/kk


3:unison参数说明(命令行使用)
  -testserver 测试连通性,连接到服务器即退出 #unison / ssh://cdn1/ -testserver  (-servercmd=/usr/bin/unison   -servercmd 参数告诉要执行的服务器 unison 命令位置)
  -auto  #接受缺省的动作,然后等待用户确认是否执行
  -batch #batch mode, 全自动模式,接受缺省动作,并执行
  -ignore xxx #增加 xxx 到忽略列表中
  -ignorecase [true|false|default] #是否忽略文件名大小写
  -follow xxx #是否支持对符号连接指向内容的同步
  -silent #安静模式
  -times #同步修改时间
  -path  #参数指定的子目录以及文件,而非整个目录。-path 可以多次出现
  
4:通过配置文件来使用unison
配置文件在/root/.unison下,缺省的配置文件为: “default.prf”。
unison会到在 ~/.unison 目录下查找 “.prf” 配置文件,如果不带参数执行 unison,则查找 “default.prf” 文件


root = /mnt/data/  
root = ssh://root@djmalai:7823//mnt/data/   #两个root为同步的目录
force = /mnt/data/                          #开启force后为单向同步
path = xl         #PATH为指定同步的目录
path = xl/versions/djwy                     
path = xl/versions/pzero                    
ignore = Path xl/versions                   #忽略同步的目录
ignore = Path xl/wlyserver                  
ignore = Path xl/www/debian163              
auto = true                                 
batch = true                                #全自动模式,接受并执行默认动作 
maxthreads = 500                            #同步时最大线程数为500
perms = -1                                  #保持同步过来读写权限
repeat = 60                                 #间隔60秒后,开始新一次同步检查 
retry = 99999999                            #重试次数
sshargs = -C -i /etc/default/unison_key     #使用ssh压缩传输方式
ferbycopying = true                         #
fastcheck = true                            #true表示同步时通过文件的创建时间来比较两地文件,若为false,则比较两地文件的内容
log = true                                        
logfile = /var/log/unison/unison.log      
djmalai.prf (END)           


缺点:对于一个文件在两个同步文件夹中都被修改时,unison是不会去同步的,因为unison无法判断以那个为准。
原创粉丝点击