3.2.unison 命令
- 3.2.1. unison 命令行
- 3.2.2. 常用参数
- 3.2.3.模式匹配
- 3.2.4. 应用举例
- 3.2.5. unison 配置文件
- 3.2.6. FAQ
Unison 是一个文件同步工具,采用 rsync 类似的算法,但是提高了一步,双向同步以及一个统一的版本控制系统。
3.2.1.unison 命令行
可以用如下格式调用 unison
3.2.2.常用参数
3.2.3.模式匹配
如下参数ignore/ignorenot, follow, sortfirst/sortlast, backup, merge定义各自的匹配模式。 例如: ignore = pattern
pattern 的语法格式
以下通配符可以用在 Path 和 Name中:
示例:
3.2.4.应用举例
3.2.5.unison 配置文件
3.2.5.1..unison 目录
~/.unison目录保存用户配置文件以及 Archive 文件。
配置文件扩展名为.prf,缺省的配置文件为: "default.prf"。
Archive文件可能有多个,每对同步的对象对应一个文件。这个文件记录了文件的状态,可以在后续的更新动作中更快速的判断文件的更新动作。Archive 文件名和双方的主机名、路径名等相关。
Archive 虽然自动由 unison维护,但是特殊情况下(如本机的地址经常变更),可以利用下面的方法:
3.2.5.2.*.prf 配置文件
如果 unison只带一个参数执行,如
unison
则在 ~/.unison 目录下查找".prf" 配置文件。
如果不带参数执行 unison,则查找"default.prf" 文件。
3.2.5.3..prf 文件示例
3.2.6.FAQ
3.2.6.1.ssh 超时问题
和远程服务器同步大量数据,上传一部分数据后,超时:
9% 559:15 ETARead from remote host bluehost: Connection reset by peerFatal error: Lost connection with the server
Google 搜索类似问题:
该文章提出增大 ssh 超时时间设置:http://groups.yahoo.com/group/unison-users/message/3403hello users, I am trying to run unison to sync up 2 different servers.The directory I am syncing is pretty large... about 3000 subdirs andeach of those subdirs has a couple dozen dirs under them. About 80 GBsof data total.I am using the following command:unison -batch /dir/path ssh://remoteserver//dir/pathI originally used rsync to move the directory over to the remoteserver however I now have a need for bidirectional mirroring hence thereason why I now use unison.When I run this command, I get the usual warning about no prior indexfound since this is the first run.Unison then begins to list all the dirs and subdirs (building theindex dbase I suppose). When it's almost finished, I get the followinglines:Waiting for changes from serverFatal Error: Lost connection with serverI have used unison before to mirror directories between these twomachines, but none of which were this big with so many subdir branches.Nothing in any logs to give me any clues. I though it might be somesort of ssh timeout, so I added "ConnectTimeout 10" in/etc/ssh/ssh_config to give it a 10 second timeout, but I dont thinkthis will help since the ssh session does indeed connect initially.ulimit -s shows I have an 8MB stack size.Can anyone shed any light onto this problem?Thank you
另外一个用户提出将一个任务分解成多个任务的方法:
http://groups.yahoo.com/group/unison-users/message/3651The connection between the client and the server can remain idle for along time when checking for updates. So, if there is a masqueradingrouter (or a firewall using stateful inspection) between the clientand the server, it may wrongly consider that the connection is deadafter some time.The usual workaround is to use the path directive to synchronizesmaller parts of the replica at a time. This should necessary onlyfor the first synchronization, as the subsequent ones are much faster.You could also try to use the ServerAliveInterval directive of ssh inorder to keep the connection active.
实际操作中,第一次,我先把要上传的文件打成包,用 ftp 上传,然后展开到服务器中,之后执行一次 unison 同步即可