Current Articles | RSS Feed
# yum install unison
$ unison ssh://user@remote_server//data_backup/ data_dir/
-ui
text
$ unison -ui text ssh://user@remote_server//data_backup/ data_dir/
root = data_dir/root = ssh://user@remote_server//data_backup/
unison test
path = a/path = b/
batch
auto
batch = trueauto = trueignore = Name *.bakignore = Name ~*
perm = 0
$ cat ~/.unison/parentroot = data_dir/root = ssh://user@remote_server//data_backup/batch = trueignore = Name *.bakinclude parent$ cat ~/.unison/patha.prfpath = a/include parent$ cat ~/.unison/pathb.prfpath = b/include parent$ cat ~/.unison/test.prfinclude parent
unison patha
unison -socket 2244
root = socket://unison-server:2244//data_backup/
-rsync
false
unison -rsync=false ssh://user@remote_server//data_backup/ data_dir/
Unison works by executing fstat system call on each file descriptor, which returns a bunch of information about each file, including its inode, size, and owner. This means that, more than the amount of data to be transferred, the total number of inodes is the major performance bottleneck. Therefore you can synchronize a single 1GB file faster than 100 10MB files. Unison checks the inode number and modtime of a file to see whether it has changed and thus needs to be transferred. You can fool Unison by using the touch command or equivalent in Linux. Running touch file-name will change the timestamp on the file, so you can use this command to make Unison sync a particular file, even if you didn't otherwise update it.Unison by default identifies machines by their hostnames, which are set by the operating system or on the basis of their IP addresses, which are often allocated by DHCP. Since a client's IP address might change, it is a good idea to define a variable UNISONLOCALHOSTNAME and put it in each machine's .bashrc file. Unison will then identify the machine using this variable irrespective of the hostname.Unison also creates a hash of the data to be synchronized and then compares it across the machines to get the changes. This is one of the major reasons that you should initially copy the data before starting Unison for synchronization. If you do that, only a minimal number of changes will propagate. Ext3 and similar filesystems have been known to provide better performance than FAT while hashing, though you can use fastcheck option on Windows to boost the hashing speed. You also need to ensure that if you are running Unison across platforms, you should invoke Unison and control it from Linux only, because Unison is known for not handling Unicode characters properly on non-Linux platforms.While Unison has many advantages over rsync, you can make it behave like rsync for one-way sync by using the -force flag. You might want to do this when you have multiple machines to synchronize. You can arrange the clients in a virtual star topology and sync every node from one master. However, if you are sure you will need only one-way replication, you might as well just use rsync; Unison is overkill in this case and will utilize more CPU cycles than rsync.All of the above should be enough to get you started with Unison. You can customize the software further and do a lot more with this utility. To learn more about Unison, check out the Unison Manual.
touch file-name
fastcheck
-force
Follow @openlogicFollow @CloudSwing This work is licensed under a Creative Commons Attribution 3.0 Unported License.
Allowed tags: <a> link, <b> bold, <i> italics