Chinaunix首页 | 论坛 | 博客
  • 博客访问: 108420
  • 博文数量: 24
  • 博客积分: 3020
  • 博客等级: 中校
  • 技术积分: 205
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-23 16:24
文章分类
文章存档

2010年(1)

2008年(23)

我的朋友

分类: LINUX

2008-05-28 18:21:51

Although the rsync command is good to back up one machine to another, it assumes
that the machine being backed up is the only one where the data is being modified.
What if you have two machines that both modify the same file and you want to sync
those files?
Unison is a tool that will let you do that.

It’s common for people to want to work with the same documents on their laptop and
desktop systems. Those machines might even run different operating systems. Because
unison is a cross-platform application, it can let you sync files that are on both Linux and Windows systems. To use unison in SUSE, you must install the unison package.

With unison, you can define two roots representing the two paths to synchronize.
Those roots can be local or remote over ssh. For example:
$ unison /home/francois ssh://francois@server1//home/fcaen
$ unison /home/francois /mnt/backups/francois-homedir
NOTE Users have reported issues attempting to sync using unison versions
installed by default between SUSE systems and Fedora or Ubuntu systems. Be
sure to check that the versions of unison you use are at the same version number
between the platforms.
Unison contains both graphical and command-line tools for doing unison backups.
It will try to run the graphical version by default. This may fail if you don’t have a desktop running or if you’re launching unison from within screen. To force unison to run in command line mode, add the -ui text option as follows:

$ unison /home/francois ssh://francois@server1//home/fcaen -ui text
Contacting server...
password:
Looking for changes
Waiting for changes from server
Reconciling changes
local server1
newfile ----> memo.txt [f] y
Propagating updates
...
 
The unison utility will then compare the two roots and for each change that occurred since last time, ask you what you want to do. In the example above, there’s a new file called memo.txt on the local system. You are asked if you want to proceed with the update (in this case, copy memo.txt from the local machine to server1). Type y to do the updates.

If you trust unison, add -auto to make it take default actions without prompting you:

$ unison /home/francois ssh://francois@server1//home/fcaen -auto

There is no man page for unison. However, you can view unison options using the
-help option. You can also display and page through the unison manual using the
-doc all option as shown here:

$ unison -help See unison options
$ unison -doc all | less Display unison manual

If you find yourself synchronizing two roots frequently, you can create a profile, which is a series of presets. In graphical mode, the default screen makes you create profiles.

Profiles are stored in .prf text files in the ~/.unison/ directory. They can be as simple as the following:

root = /home/francois
root = ssh://francois@server1//home/fcaen
If this is stored in a profile called fc-home.prf, you can invoke it simply with the
following command line:

$ unison fc-home
 
摘自<>
阅读(979) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~