<?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>edsalisbury.net &#187; macosx</title>
	<atom:link href="http://edsalisbury.net/tag/macosx/feed/" rel="self" type="application/rss+xml" />
	<link>http://edsalisbury.net</link>
	<description>your guide to user-friendly entertainment</description>
	<lastBuildDate>Wed, 28 Mar 2012 02:07:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How To Set Up a Two-Way Mirror Between Mac OS X and Ubuntu Linux</title>
		<link>http://edsalisbury.net/how-to-set-up-a-two-way-mirror-between-mac-os-x-and-ubuntu-linux/</link>
		<comments>http://edsalisbury.net/how-to-set-up-a-two-way-mirror-between-mac-os-x-and-ubuntu-linux/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 23:11:48 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[mirroring]]></category>
		<category><![CDATA[unison]]></category>

		<guid isPermaLink="false">http://www.edsalisbury.net/?p=58</guid>
		<description><![CDATA[<a href="http://edsalisbury.net/how-to-set-up-a-two-way-mirror-between-mac-os-x-and-ubuntu-linux/" title="How To Set Up a Two-Way Mirror Between Mac OS X and Ubuntu Linux"></a>After my hard drive crash a few months ago, I&#8217;ve been a bit paranoid about losing data.   By &#8220;a bit&#8221; I mean I&#8217;ve been sticking copies of my data on different machines to make sure I have various copies in &#8230;<p class="read-more"><a href="http://edsalisbury.net/how-to-set-up-a-two-way-mirror-between-mac-os-x-and-ubuntu-linux/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://edsalisbury.net/how-to-set-up-a-two-way-mirror-between-mac-os-x-and-ubuntu-linux/" title="How To Set Up a Two-Way Mirror Between Mac OS X and Ubuntu Linux"></a><p><a href="http://www.flickr.com/photos/aloshbennett/3237417064/"><img class="alignleft size-thumbnail wp-image-82" title="Mirror to the Sky" src="http://www.edsalisbury.net/wp-content/uploads/2009/06/aloshbennett-mirror-to-the-sky-150x150.jpg" alt="Mirror to the Sky (aloshbennet CC)" width="150" height="150" /></a>After my hard drive crash a few months ago, I&#8217;ve been a bit paranoid about losing data.   By &#8220;a bit&#8221; I mean I&#8217;ve been sticking copies of my data on different machines to make sure I have various copies in case another hard drive dies, or a computer gets fried, melting everything inside, or my house burns down&#8230; Oh wait, I don&#8217;t have that scenario covered&#8230;.  Time to fix that!  What I want is the ability to copy my data to an offsite location, and keep the backup up to date.  The main thing I care about is my family photos.   I was talking to my cousin Dave, and he had the same issue.  He wanted access to my photos, as well as have an offsite backup copy of his family&#8217;s photos.  I thought of a solution.  What if we could set up a two-way mirror between his machine and mine, and keep it updated nightly?  That way if he sticks something in the directory on his machine and vice versa, keeping a live backup.  I began doing some research, and I found the tool &#8212; <a href="http://www.cis.upenn.edu/~bcpierce/unison/">Unison</a>.</p>
<p><span id="more-58"></span></p>
<p>One slight wrinkle is the fact that he runs Mac OS X and I run Ubuntu Linux.  Unison will run on both, so it should be fine.</p>
<p>A couple of things to consider:</p>
<p>Mirroring over the internet is <strong>SLOW</strong> &#8212; if you want to keep a large quantity of files mirrored, it&#8217;s best to &#8220;seed&#8221; the mirror by doing a local copy to the drive.  Dave sent me his hard drive via snailmail, so this worked out.</p>
<p>This process will involve poking holes in your firewall, and setting up SSH keys with no password.  These are security risks (which can be minimized).  You have been warned.</p>
<p>To make things easy, I&#8217;ll specify the hostnames:</p>
<p><strong>Mac Host: eve</strong></p>
<p><strong>Linux Host: twiki</strong></p>
<p>One thing needs to be decided before we go on is which host will be initiating the transfer.   You can initiate from both sides, but to make it easy, I&#8217;ll just be initiating from my computer, twiki.</p>
<p>The first step is to verify connectivity between the two machines.  Since I&#8217;m initiating the transfer, I&#8217;ll be adding a hosts entry for eve.  I first have Dave go to <a href="http://www.whatismyip.com">www.whatismyip.com</a> and have him tell me his IP address.  I put this into /etc/hosts on my machine:</p>
<pre>&lt;hismachinesipaddress&gt;        eve</pre>
<p>I try to first ping the address.  Most likely it will fail.  Dave will need to poke a hole in the firewall (set up port forwarding) &#8211; How to do this is outside the scope of this article, but <a href="http://portforward.com">www.portforward.com</a> has a lot of info on how to do this.  Dave forwards port 22 (SSH) to his local IP address and saves settings.</p>
<p>Ping still doesn&#8217;t work, but SSH should.  I try sshing to the box, and voila, I get a password prompt.</p>
<p>The next step is to have Dave create an account for me.  To make it easy, I have him call it &#8220;ed&#8221; (same as on twiki)</p>
<p>After my account has been created, I&#8217;m able to login via ssh.  The next step is to set up an SSH key to make it so that I can ssh in without having to give a password.  On twiki, I run:</p>
<pre>twiki% ssh-keygen -t dsa -f ~/.ssh/unison</pre>
<p>(Press enter when it asks for a passphrase)</p>
<p>Add the contents of ~/.ssh/unison.pub to ~/.ssh/authorized_keys2 on eve.  Make sure it&#8217;s all on one line (no linebreaks)</p>
<p>To test it out, I ssh from twiki to eve, specifying the unison key:</p>
<pre>twiki% ssh -i ~/.ssh/unison eve</pre>
<p>It shouldn&#8217;t ask me for a password, so I&#8217;m good to go for this step.  If it does, make sure the permissions on the files in ~/.ssh are set to 600.</p>
<p>Next, we&#8217;ll install Unison on both machines:</p>
<p><strong>On Eve:</strong></p>
<ul>
<li>Get and install <a href="http://darwinports.com/download/">MacPorts</a></li>
<li>Use MacPorts to install Unison:</li>
</ul>
<pre>eve% sudo /opt/local/bin/port install unison
---&gt;  Fetching ocaml
---&gt;  Attempting to fetch ocaml-3.11.0.tar.bz2 from http://distfiles.macports.org/ocaml
---&gt;  Verifying checksum(s) for ocaml
---&gt;  Extracting ocaml
---&gt;  Configuring ocaml
---&gt;  Building ocaml
---&gt;  Staging ocaml into destroot
---&gt;  Installing ocaml @3.11.0_0
---&gt;  Activating ocaml @3.11.0_0
---&gt;  Cleaning ocaml
---&gt;  Fetching unison
---&gt;  Attempting to fetch unison-2.27.57.tar.gz from http://distfiles.macports.org/unison
---&gt;  Verifying checksum(s) for unison
---&gt;  Extracting unison
---&gt;  Applying patches to unison
---&gt;  Configuring unison
---&gt;  Building unison
---&gt;  Staging unison into destroot
---&gt;  Installing unison @2.27.57_0
---&gt;  Activating unison @2.27.57_0
---&gt;  Cleaning unison</pre>
<p><strong>On Twiki:</strong></p>
<pre>twiki% sudo apt-get install unison
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
unison
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 0B/529kB of archives.
After this operation, 1262kB of additional disk space will be used.
(Reading database ... 150151 files and directories currently installed.)
Unpacking unison (from .../unison_2.27.57-1ubuntu1_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for doc-base ...
Processing 1 added doc-base file(s)...
Registering documents with scrollkeeper...
Setting up unison (2.27.57-1ubuntu1) ...</pre>
<p>Next, set up the profile on twiki:</p>
<pre>twiki% mkdir ~/.unison
twiki% vi ~/.unison/default.prf</pre>
<p>Put the following into default.prf (changing as appropriate):</p>
<pre>root = /data/EdsPhotos
root = ssh://eve//DavesPhotos
rshargs = -C
sshargs = -i /home/ed/.ssh/unison
servercmd = /opt/local/bin/unison
ignore = Name _*
ignore = Name .*
batch = true
log = true</pre>
<p>For security purposes, add the following to ~/.ssh/authorized_keys2 on eve.  This will only allow this ssh key to be used to run unison:</p>
<pre>command="/opt/local/bin/unison",no-port-forwarding,no-X11-forwarding,no-agent-forwarding</pre>
<p>On twiki, run unison:</p>
<pre>twiki% unison</pre>
<p>It will spit out a lot of data, but should start scanning and eventually copying data back and forth, depending on how much data there is.   In order to run nightly, add the following to your crontab on twiki:</p>
<pre>0 0 * * * nohup /usr/local/bin/unison &gt; /dev/null 2&gt;&amp;1</pre>
<p>That should be it.  Any feedback would be appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://edsalisbury.net/how-to-set-up-a-two-way-mirror-between-mac-os-x-and-ubuntu-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

