------------------------------------------------------------------------------- Unison Hint and Tips An alternative to unison is a purely script based directory syncronization... https://github.com/Fitus/Zaloha.sh ------------------------------------------------------------------------------- Unison and Hostames Unison uses the machines "hostname" (via the gethostname() system call) to identify that machine however this may not be unique, and could vary based on the machines location and its DHCP network connection. The environment variable UNISONLOCALHOSTNAME can be used to specify the hostname in the archive data files of this machine (in both local and remote data files). It can also be used to give the machine a shorter name. However it must be setup in the Shell's Startup RC files, for remote logins. For example I typically use the machines official 'short' name to identify it rather than a machines full network name. ------------------------------------------------------------------------------- Wrapped SSH I also use a wrapper around the SSH command, both for unison and for normal use. In my case the wrapper script is simply "r" (historical reasons). This wrapper generally allows you to specify short aliases and does DNS lookups regardless of what the DHCP or DNS search domains have set. It also looks up the loginname I use for my account on the various machines, and allows me to define personal aliases and names for remote machines. I found this vital as I have access to over 500 machines, some with different account names and Operating Systems! For example a hostname of "h" is short for "home laptop via home router" making it easy for me to remotely connect to machines without a lot of typing or looking up account information for that machine. The "r" command also deals with a special hostname "UNISON_ALT_HOME", that I use in "unison" represent my 'other home' (work or home laptop) in configuration files. That way I can use exactly the same configuration file on my home or work machine. The ssh wrapper on seeing this hostname replaces it with the value of the environment variable "$UNISON_ALT_HOME" on the current machine on the current machine. The actual name used in the checksum archives is still set as per the "$UNISONLOCALHOSTNAME" environment variable. At work I then have following environment variables UNISONLOCALHOSTNAME=zombie # short name of my machine at work UNISON_ALT_HOME=lamia # name of my machine at home and at home I have UNISONLOCALHOSTNAME=lamia UNISON_ALT_HOME=zombie Unison synchronization file, "home.prf", contains the following definitions... =======8<-------- label = "Home Directory Sync" root = root = ssh://UNISON_ALT_HOME/ sshcmd = r sshargs = -x =======8<-------- That means I can simply use "unison home" on either machine and "unison" will call the 'other machine' and still use the right name in the archives (from $UNISONLOCALHOSTNAME), regardless of which machine I ran the "unison" command on. That is the two machines will be synchronised, and use the same archive files regardless of where I launched it. ------------------------------------------------------------------------------- Ignore specific 'dot' files... These are things I globally ignore anyway... EG: ignore = Name .xvpics # XV thumbnail image directories ignore = Name .*.swp # VIM editor backup files ignore = Name .*~ # Emacs editor Backup Files ------------------------------------------------------------------------------- Ignore a whole directory, except a single file deep within This is now easy... path = BelowPath {directory or file} Examples path = BelowPath .mozilla/firefox/default/places.sqlite* path = BelowPath .config/google-chrome*/Default/Bookmarks ------------ BEFORE Unison v2.40, this was actyually very tricy to do You had to include each parent directory but not the directories contents. Say you want to Say you are syncronising directory "a" (EG path = a ) But you want to ignore everything in the directory "a/b" except the specific file "a/b/c/data" That is you want "unison" to syncornize that file, but ignore everything else. However to do that you have to tell "unison" not to igonre the parent directories of that file!!! Here is how to do it... path = a # Do not ignore directory "a/b", just its contents... ignore = Path a/b/* # Don't ignore the parent directory of the file. ignorenot = Path a/b/c # But everything else in that directory ignore = Path a/b/c/* # Except the file/directory we are really interested in synchronizing ignorenot = Path a/b/c/data WARNING: If you have 'dot' files or directories within this path you also have to specifically ignore them too! ignore = Path a/b/{.?,.??*,*} It's a real pain to have to repeat this sequence down the whole directory path leading up to the file, but that is the way it works. If you have multiple files, or directory paths you can combine the ignorenot's together using '{}'. EG that last could be... # do not ignore file "data" and sub-directories "x" and "y" ignorenot = PATH a/b/c/{data,x,y} # Ignore the contents of those directories ignore = PATH a/b/c/{x,y}/* # Don't ignore these specific files in those sub-directories ignorenot = PATH a/b/c/{x/this,y/that} ASIDE: The "rsync" command is also simularly awkward, in ignoring a sub-irectory contents, except for one specific file deep in its structure. -------------------------------------------------------------------------------