Difference between revisions of "Unison"

From ArchWiki
Jump to: navigation, search
m (agreed on a name for Unison)
(24 intermediate revisions by 10 users not shown)
Line 1: Line 1:
[[Category:HOWTOs (English)]]
+
[[Category:Internet Applications]]
[[Category:Networking (English)]]
+
'''Unison''' is a bidirectional file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.
[[Category:Daemons and system services (English)]]
+
'''Unison''' is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.
+
  
 
Not only can Unison sync between Windows and Unix ( OSX, Solaris, Linux etc.) systems, it also unrestricted in terms of which system can be the host.
 
Not only can Unison sync between Windows and Unix ( OSX, Solaris, Linux etc.) systems, it also unrestricted in terms of which system can be the host.
Line 10: Line 8:
 
==Installation==
 
==Installation==
 
  # pacman -S unison
 
  # pacman -S unison
This provides the Unison GTK2 frontend.
+
This provides a CLI and GTK+ 1 & 2 frontends.
 +
 
 +
Offline documentation is available in the {{AUR|unison-doc}} AUR package.
  
 
==Configuration==
 
==Configuration==
In order to use Unison you need to create an profile, you can use a GUI or you can manually create a profile in {{Filename|~/.unison}}.
+
In order to use Unison, you need to create a profile. You can use the supplied GUI tool or you can manually create a profile in {{ic|~/.unison}}.
  
If you want to use the GUI, run:
+
If you want to use the GUI configuration, run:
 
  $ unison-gtk2
 
  $ unison-gtk2
Else edit the default config file:
+
Otherwise, edit the default config file:
  # nano ~/.unison/default.perf
+
  # nano ~/.unison/default.prf
  
First we define the root of what you want to sync:
+
First, define the root of what you want to sync:
 
  root=/home/user/
 
  root=/home/user/
  
Then we define the root where we sync it too:
+
Then, define the root of where to sync it to:
 
  root=ssh://example.com//path/to/server/storage
 
  root=ssh://example.com//path/to/server/storage
Optionaly, you can give arguments to ssh:
+
 
 +
Optionally, you can give arguments to SSH:
 
  sshargs=-p 4000
 
  sshargs=-p 4000
  
Now we are going to define with directories and files we want to include in the sync
+
Now you are going to define which directories and files to include in the sync:
 
  # dirs
 
  # dirs
 
  path=Documents
 
  path=Documents
Line 45: Line 46:
  
 
==Usage==
 
==Usage==
When your profile is setup you can start syncing:
+
Once your profile is set up, you can start syncing:
  $ unsion <profilename>
+
  $ unison <profilename>
Or:
+
or using the GUI tool:
  unision-gtk2
+
  unison-gtk2
And select the profile. Unison has a nice interface where you can view the progress and changes.
+
and select the profile. Unison has a nice interface where you can view the progress and changes.
  
==External Links==
+
==Version Incompatibility==
*[http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#afterinstall Official User Manual and Reference Guide, Section "Running Unison"]
+
For Unison to function properly, the same version ''must'' be installed on all clients. If, for example, one computer has version 2.40 and the other has 2.32, they will not be able to sync with each other. This applies to ''all'' computers that share a directory to be synchronized across your machines.
  
*[http://www.endperform.org/2007/07/howto-backup-and-sync-with-unison/ HOWTO: Backup and Sync with Unison], ''[http://www.endperform.org endperform.org]''
+
Due to the staggered releases with varying Linux distros, you might be stuck with older versions of Unison, while Arch Linux has the latest upstream version in the Extra repository. There are unofficial [[PKGBUILD]]s for versions [https://aur.archlinux.org/packages.php?ID=46811 2.32] and [https://aur.archlinux.org/packages.php?ID=46823 2.27] on the [[AUR]] that allow users of multiple distros to continue using Unison with their existing systems.
 +
 
 +
==Tips & Tricks==
 +
===Save human time and keystrokes===
 +
If one runs unison within a VDT emulator capable of maintaining a suitable scrollback buffer, there is no purpose in having to confirm every non-conflicting change; set the {{ic|auto}} option to true to avoid these prompts.
 +
 
 +
===Common config sync===
 +
When syncing configuration files which would vary (e.g., due to endemic applications, security-sensitive configuration) among systems (servers, workstations, laptops, smartphones, etc.) but nevertheless contain common constructs (e.g., key bindings, basic shell aliases), it would be apt to separate such content into separate config files (e.g., {{ic|.bashrc_common}}), and sync only these.
 +
 
 +
{{Warning|Bidirectional syncing of config files can lend itself to become an avenue for an attack, by enabling the peer syncing system to receive malicious changes to config files (and perhaps even other peers the system syncs with). This is an attractive option for adversaries, especially when the conceptual security levels of the two systems differ (e.g., public shell server vs. personal workstation), since it would likely be simpler to compromise a system of lower security. Always use the {{ic|noupdate}} option when bidirectional syncing between two particular systems is deemed unnecessary; when necessary, verify each change when syncing. Automatic bidirectional syncs should be done with extreme caution.}}
 +
 
 +
==See Also ==
 +
*[http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#afterinstall Official User Manual and Reference Guide, Section "Running Unison"]
 +
*[http://www.stanford.edu/~pgbovine/unison_guide.htm Useful advice]

Revision as of 06:52, 29 November 2012

Unison is a bidirectional file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.

Not only can Unison sync between Windows and Unix ( OSX, Solaris, Linux etc.) systems, it also unrestricted in terms of which system can be the host.

Common uses include syncing configuration files, photos, and other content.

Installation

# pacman -S unison

This provides a CLI and GTK+ 1 & 2 frontends.

Offline documentation is available in the unison-docAUR AUR package.

Configuration

In order to use Unison, you need to create a profile. You can use the supplied GUI tool or you can manually create a profile in ~/.unison.

If you want to use the GUI configuration, run:

$ unison-gtk2

Otherwise, edit the default config file:

# nano ~/.unison/default.prf

First, define the root of what you want to sync:

root=/home/user/

Then, define the root of where to sync it to:

root=ssh://example.com//path/to/server/storage

Optionally, you can give arguments to SSH:

sshargs=-p 4000

Now you are going to define which directories and files to include in the sync:

# dirs
path=Documents
path=Photos
path=Study
# files
path=.bashrc
path=.vimrc

You can also define which files to ignore:

ignore=Name temp.*
ignore=Name .*~
ignore=Name *.tmp

For further references check the Unison documentation.

Usage

Once your profile is set up, you can start syncing:

$ unison <profilename>

or using the GUI tool:

unison-gtk2

and select the profile. Unison has a nice interface where you can view the progress and changes.

Version Incompatibility

For Unison to function properly, the same version must be installed on all clients. If, for example, one computer has version 2.40 and the other has 2.32, they will not be able to sync with each other. This applies to all computers that share a directory to be synchronized across your machines.

Due to the staggered releases with varying Linux distros, you might be stuck with older versions of Unison, while Arch Linux has the latest upstream version in the Extra repository. There are unofficial PKGBUILDs for versions 2.32 and 2.27 on the AUR that allow users of multiple distros to continue using Unison with their existing systems.

Tips & Tricks

Save human time and keystrokes

If one runs unison within a VDT emulator capable of maintaining a suitable scrollback buffer, there is no purpose in having to confirm every non-conflicting change; set the auto option to true to avoid these prompts.

Common config sync

When syncing configuration files which would vary (e.g., due to endemic applications, security-sensitive configuration) among systems (servers, workstations, laptops, smartphones, etc.) but nevertheless contain common constructs (e.g., key bindings, basic shell aliases), it would be apt to separate such content into separate config files (e.g., .bashrc_common), and sync only these.

Warning: Bidirectional syncing of config files can lend itself to become an avenue for an attack, by enabling the peer syncing system to receive malicious changes to config files (and perhaps even other peers the system syncs with). This is an attractive option for adversaries, especially when the conceptual security levels of the two systems differ (e.g., public shell server vs. personal workstation), since it would likely be simpler to compromise a system of lower security. Always use the noupdate option when bidirectional syncing between two particular systems is deemed unnecessary; when necessary, verify each change when syncing. Automatic bidirectional syncs should be done with extreme caution.

See Also