<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SavvyAdmin.com &#187; Unison</title>
	<atom:link href="http://savvyadmin.com/tag/unison/feed/" rel="self" type="application/rss+xml" />
	<link>http://savvyadmin.com</link>
	<description>For savvy admins everywhere...</description>
	<lastBuildDate>Fri, 21 Jan 2011 17:53:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>File Synchronization with Unison over SSH</title>
		<link>http://savvyadmin.com/file-synchronization-with-unison-over-ssh/</link>
		<comments>http://savvyadmin.com/file-synchronization-with-unison-over-ssh/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 01:36:25 +0000</pubDate>
		<dc:creator>gmendoza</dc:creator>
				<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Rsync]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Unison]]></category>

		<guid isPermaLink="false">http://www.savvyadmin.com/?p=318</guid>
		<description><![CDATA[Previously, I posted on using rsync over SSH for file synchronization. While this works very well when pushing data in one direction, it&#8217;s not well suited for synchronizing modifications that are made on both sides. An excellent bidirectional utility for that type of job is Unison, which sports many of the same benefits as rsync, [...]
Related posts:<ol>
<li><a href='http://savvyadmin.com/file-synchronization-with-rsync-over-ssh/' rel='bookmark' title='File Synchronization with Rsync over SSH'>File Synchronization with Rsync over SSH</a></li>
<li><a href='http://savvyadmin.com/backup-delivery-via-ssh/' rel='bookmark' title='Backup Delivery via SSH'>Backup Delivery via SSH</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Previously, I <a target="_blank" href="/file-synchronization-with-rsync-over-ssh/">posted</a> on using <em>rsync</em> over SSH for file synchronization.  While this works very well when pushing data in one direction, it&#8217;s not well suited for synchronizing modifications that are made on both sides.  An excellent bidirectional utility for that type of job is <em><a target="_blank" href="http://www.cis.upenn.edu/~bcpierce/unison/index.html">Unison</a></em>, which sports many of the same benefits as rsync, but has some distinct advantages for more complex synchronization scenarios.</p>
<p>A basic example would be to synchronize a local directory called &#8220;<em>MyDocs</em>&#8221; with a remote SSH server.  From the following output, you can see that this directory contains four text files.</p>
<blockquote><p><code><strong>ls -ld ~/MyDocs</strong><br />
drwxr-xr-x 2 gmendoza gmendoza 4096 2009-04-09 16:05 /home/gmendoza/MyDocs</code></p>
<p><code><strong>ls -l ~/MyDocs</strong><br />
total 12<br />
-rw-r--r-- 1 gmendoza gmendoza 31 2009-04-09 16:09 file1.txt<br />
-rw-r--r-- 1 gmendoza gmendoza 31 2009-04-09 16:09 file2.txt<br />
-rw-r--r-- 1 gmendoza gmendoza 31 2009-04-09 16:09 file3.txt<br />
-rw-r--r-- 1 gmendoza gmendoza 31 2009-04-09 16:09 file4.txt</code></p></blockquote>
<p>The first time you run Unison for this particular directory structure, both sides will create a local index and hash table.  You&#8217;ll get a warning and will be prompted with a message, asking you to hit the space bar if you accept.  If the root directory on the remote side does not exist yet, you&#8217;ll also be prompted to accept the changes.</p>
<blockquote><p><code><strong>unison MyDocs ssh://host2/MyDocs</strong><br />
Contacting server...<br />
Connected [//host1//home/gmendoza/MyDocs -> //host2//home/gmendoza/MyDocs]<br />
Looking for changes<br />
Warning: No archive files were found for these roots, whose canonical names are:<br />
	/home/gmendoza/MyDocs<br />
	//host2//home/gmendoza/MyDocs<br />
<em>(snipped for brevity...)</em><br />
Press return to continue.[<strong><spc></strong>]    Waiting for changes from server<br />
Reconciling changes</code></p>
<p><code>local          host2<br />
dir      ---->            /  [<strong>f</strong>] </code></p>
<p><code>Proceed with propagating updates? [] <strong>y</strong><br />
Propagating updates</code></p>
<p><code>UNISON 2.27.57 started propagating changes at 16:14:30 on 09 Apr 2009<br />
[BGN] Copying  from /home/gmendoza/MyDocs to //host2//home/gmendoza/MyDocs<br />
[END] Copying<br />
UNISON 2.27.57 finished propagating changes at 16:14:30 on 09 Apr 2009</code></p>
<p><code>Saving synchronizer state<br />
Synchronization complete  (1 item transferred, 0 skipped, 0 failures)</code></p></blockquote>
<p>Subsequent synchronizations are shown as the following.</p>
<blockquote><p><code><strong>unison MyDocs ssh://host2/MyDocs</strong><br />
Contacting server...<br />
Connected [//host1//home/gmendoza/MyDocs -> //host2//home/gmendoza/MyDocs]<br />
Looking for changes<br />
  Waiting for changes from server<br />
Reconciling changes<br />
Nothing to do: replicas have not changed since last sync.</code></p></blockquote>
<p>For the following example, I have modified file1.txt on host1, and file2.txt on host2.  Both file3.txt and file4.txt have been modified on each side.  The great thing about <em>unison</em> is that when there is a conflict, you have the opportunity to view the differences and select which direction you wish to synchronize.  Pressing the &#8220;x&#8221; key displays some basic information about the files that differ.  In this case, I have chosen the files with the most recent timestamp.  You choose the file direction by pressing the greater and less-than symbols, &#8220;>&#8221; and &#8220;<".</p>
<blockquote><p><code><strong>unison MyDocs ssh://host2/MyDocs</strong><br />
(snipped)<br />
local          host2<br />
changed  <-?-> changed    file3.txt  [] <strong>x</strong><br />
local        : changed file       modified on 2009-04-09 at 16:16:29  size 50<br />
host2  : changed file       modified on <strong>2009-04-09 at 16:16:43</strong>  size 55<br />
changed  <==== changed    file3.txt  [] <strong><</strong><br />
changed  <-?-> changed    file4.txt  [] <strong>x</strong><br />
local        : changed file       modified on <strong>2009-04-09 at 16:17:20</strong>  size 56<br />
host2  : changed file       modified on 2009-04-09 at 16:16:59  size 41<br />
changed  ====> changed    file4.txt  [] <strong>></strong><br />
changed  ---->            file1.txt  [<strong>f</strong>]<br />
         <---- changed    file2.txt  [<strong>f</strong>] </code></p>
<p><code>Proceed with propagating updates? [] <strong>y</strong><br />
Propagating updates</code></p>
<p><code>UNISON 2.27.57 started propagating changes at 16:18:27 on 09 Apr 2009<br />
[BGN] Updating file file3.txt from //host2//home/gmendoza/MyDocs to /home/gmendoza/MyDocs<br />
[BGN] Updating file file4.txt from /home/gmendoza/MyDocs to //host2//home/gmendoza/MyDocs<br />
[BGN] Updating file file1.txt from /home/gmendoza/MyDocs to //host2//home/gmendoza/MyDocs<br />
[BGN] Updating file file2.txt from //host2//home/gmendoza/MyDocs to /home/gmendoza/MyDocs<br />
[END] Updating file file3.txt<br />
[END] Updating file file2.txt<br />
[END] Updating file file4.txt<br />
[END] Updating file file1.txt<br />
UNISON 2.27.57 finished propagating changes at 16:18:27 on 09 Apr 2009</code></p>
<p><code>Saving synchronizer state<br />
Synchronization complete  (4 items transferred, 0 skipped, 0 failures)</code></p></blockquote>
<p>Unison also has a GTK front end for the graphically inclined.  Be sure to check out all the documentation for a full understanding of syntax.</p>
<p>Related posts:<ol>
<li><a href='http://savvyadmin.com/file-synchronization-with-rsync-over-ssh/' rel='bookmark' title='File Synchronization with Rsync over SSH'>File Synchronization with Rsync over SSH</a></li>
<li><a href='http://savvyadmin.com/backup-delivery-via-ssh/' rel='bookmark' title='Backup Delivery via SSH'>Backup Delivery via SSH</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://savvyadmin.com/file-synchronization-with-unison-over-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

