{"id":64,"date":"2007-07-04T20:53:48","date_gmt":"2007-07-04T19:53:48","guid":{"rendered":"https:\/\/www.dont-panic.cc\/capi\/2007\/07\/04\/sharing-and-synchronizing-data-across-multiple-computers\/"},"modified":"2007-07-04T20:54:45","modified_gmt":"2007-07-04T19:54:45","slug":"sharing-and-synchronizing-data-across-multiple-computers","status":"publish","type":"post","link":"https:\/\/www.dont-panic.cc\/capi\/2007\/07\/04\/sharing-and-synchronizing-data-across-multiple-computers\/","title":{"rendered":"Sharing and Synchronizing Data Across Multiple Computers"},"content":{"rendered":"<p>I have several computers, one at the office (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Microsoft_Windows\">Windows Vista<\/a>), one at home (<a href=\"http:\/\/www.gentoo.org\">Gentoo Linux<\/a>), and one notebook (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Microsoft_Windows\">Windows XP<\/a>). On most of them I want to share a common set of files, including letters and other documents, but also Miranda. This time I am going to tell you how I keep my shared data in sync using <a href=\"http:\/\/www.cis.upenn.edu\/~bcpierce\/unison\/\">Unison<\/a>, <a href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/\">PuTTY<\/a>, and <a href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/\">OpenSSH<\/a>, using a dedicated server as central hub.<\/p>\n<p>(Note: this is a rather advisory level HOWTO, not a step-by-step, command-by-command tutorial. It might give you some ideas nevertheless.)<\/p>\n<p><!--more--><\/p>\n<p>This version of my synchronization solution is based on a central dedicated server on which you can install Unison and login via SSH using public key authentication. You can also do the same with an external media, like an USB-Stick, but there you could use the external media directly without syncing. I would recommend using synching even in this case, as Flash-based media like most USB memory sticks only have limited write cycles. Additionally, if you use synching, you get some redundancy (I wouldn&#8217;t go as far as call it &#8220;backup&#8221;) in case one of your storage devices fails.<\/p>\n<p><strong>Step 1 &#8211; Preparation<\/strong><\/p>\n<p><a href=\"http:\/\/www.cis.upenn.edu\/~bcpierce\/unison\/\">Unison<\/a> is one of my favorite two-way synchronization tools. It works by keeping a database for every replica, so it can detect new, modified, and deleted files. The program was originally target at Linux, but there is a client for Windows as well, which works well. Its major advantage in my opinion is that it uses the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Rsync\">rsync<\/a>-protocol for transferring the data, which keeps the ordinary synchronization bandwidth reasonably small.<\/p>\n<p>You have to install Unison on every client that is going to participate. <em>Important: you need to install the same version for every peer!<\/em><\/p>\n<p><strong>Step 2 &#8211; The Central Hub<br \/>\n<\/strong><\/p>\n<p>Then you need the central server. I am using a Gentoo-based dedicates server at <a href=\"http:\/\/www.hetzner.de\">Hetzner<\/a>. You don&#8217;t need a real server, but it must be an &#8220;always-on&#8221;, always reachable computer. It could be your gateway at home, but keep in mind you need to contact the host. Consider using <a href=\"http:\/\/de.wikipedia.org\/wiki\/DynDNS\">DynDNS<\/a> or similar services if you don&#8217;t have a static IP for the box. The server can even be one of the target computers, but as mentioned, it needs to be reachable via the Internet for the other sync-partners.<\/p>\n<p>I created a dm_crypt encrypted partition of 1GB size and mounted it at \/home\/martin\/shared. The 1GB size is enough for me, in fact, the shared data is around 100MB. I am sharing data, not programs or (large) multimedia files.<\/p>\n<p><strong>Step 3 &#8211; Configuring a Linux Peer<br \/>\n<\/strong><\/p>\n<p>Configuration of a Linux peer is the easier than configuration of a Windows peer, that&#8217;s why I am starting with this. First you need to create a SSH-key which will be used for authentication if you don&#8217;t already have one. Unison needs to be able to login via SSH without user interaction, still I do not recommend to create a key without passphrase. Protect the key with a passphrase, but use something like <a href=\"http:\/\/www.gentoo.org\/proj\/en\/keychain\/\">keychain<\/a> to authenticate only once against the key before starting your synchronization.<\/p>\n<p>You need to add the key to the ~\/.ssh\/authorized_keys2 file <em>at the central hub<\/em>. Ensure you can now login as the desired user using ssh <em>without a password prompt<\/em>.<\/p>\n<p>Once SSH is working, you can create a profile for unsion, like my <em>shared.prf<\/em>:<\/p>\n<blockquote><p><code>root = \/home\/martin<br \/>\nroot = ssh:\/\/martin@&lt;server&gt;\/\/home\/martin<br \/>\npath = shared<br \/>\nignore = Path {shared\/local}<\/code><\/p><\/blockquote>\n<p>This profile synchronizes the ~\/shared\/ directory to the central hub&#8217;s ~\/shared\/ directory, ignoring anything at ~\/shared\/local, which gives you the easy possibility to exclude some of your files from synchronization.<\/p>\n<p>That&#8217;s it, you can now synchronize the Linux host to the central hub. Do this anytime you quit working with the computer to prevent conflicts due to concurrent modifications on different workstations.<\/p>\n<p><strong>Step 4 &#8211; Configuring a Windows Peer<\/strong><\/p>\n<p>Windows configuration is a little bit different (but not much). First I create a <a href=\"http:\/\/www.truecrypt.org\/\">TrueCrypt<\/a> volume of the desired size. I like to have all shared folders at the same location, just out of habit. So I mount them all at S:\\ and create a #shared subdirectory, which is going to contain the shared files. (Using TrueCrypt is entirely optional and not required, I just want to make it thieves a little bit harder to read my personal data.)<\/p>\n<p>Then you need to have <a href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/\">PuTTY<\/a> (including plink and (advisable) pageant). Create a key and add it to the central hub&#8217;s ~\/.ssh\/authorized_keys2 files. I again advise against keys without password. Use pageant to cache the credentials for synchronization.<\/p>\n<p>The Unison profile needs to be different for Windows, as you need to convince Unison to use PuTTY instead of ssh. Therefore a small batch-script is required, I call it <code>launcher_server.cmd<\/code> (containing just one line, remove the word wrap):<\/p>\n<blockquote style=\"text-align: left\"><p><code>@\"C:\\Program Files\\PuTTY\\plink.exe\" -i \"S:\\putty-key.ppk\" martin@my.server.domain unison -server<\/code><\/p><\/blockquote>\n<p>Make sure the connection is able to login without further authentication.<\/p>\n<p>The <code>shared.prf<\/code> needs to be a little bit different here:<\/p>\n<blockquote><p><code>root = S:\/#shared<br \/>\nroot = ssh:\/\/martin@&lt;server&gt;\/\/home\/martin<br \/>\nsshcmd = S:\/Program Files\/Unison\/launcher_server.cmd<br \/>\nfastcheck = true<br \/>\npath = shared<br \/>\nignore = Path {shared\/local}<\/code><\/p><\/blockquote>\n<p>(Note: the &#8220;fastcheck&#8221; attribute is optional, but I recommend using it on Windows, but see the <a href=\"http:\/\/www.cis.upenn.edu\/~bcpierce\/unison\/download\/releases\/stable\/unison-manual.html#fastcheck\">Unison documentation<\/a> for further infos before using it!)<\/p>\n<p><strong> Step 5 &#8211; Synchronize<\/strong><\/p>\n<p>After you have set up all the hosts you want to participate, simply use it. Use keychain and pageant to ensure you don&#8217;t need a password for login at the central hub.  You should synchronize whenever you log off or shut down a workstation, to ensure there will be as little conflicts as possible. As long as you don&#8217;t create conflicts, even concurrent modifications can be handled automatically.<\/p>\n<p>And now, have fun and enjoy working with a consistent dataset over multiple computers. \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have several computers, one at the office (Windows Vista), one at home (Gentoo Linux), and one notebook (Windows XP). On most of them I want to share a common set of files, including letters and other documents, but also Miranda. This time I am going to tell you how I keep my shared data &hellip; <a href=\"https:\/\/www.dont-panic.cc\/capi\/2007\/07\/04\/sharing-and-synchronizing-data-across-multiple-computers\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Sharing and Synchronizing Data Across Multiple Computers&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5,10],"tags":[36,44,43],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-internet","category-software","category-sysadmin","tag-howto","tag-synchronization","tag-unison"],"_links":{"self":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":0,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}