<?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>Chunhao&#039;s Blog &#187; ssh</title>
	<atom:link href="http://chunhao.net/blog/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://chunhao.net/blog</link>
	<description>Life happens. Love helps.</description>
	<lastBuildDate>Fri, 28 May 2021 12:36:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>How to synchronize with SSH</title>
		<link>http://chunhao.net/blog/how-to-synchronize-with-ssh/</link>
		<comments>http://chunhao.net/blog/how-to-synchronize-with-ssh/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 06:08:26 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[synchronize]]></category>

		<guid isPermaLink="false">http://chunhao.net/blog/?p=52</guid>
		<description><![CDATA[I will share my experience in synchronizing files with SSH here. Following are demonstrated by synchronizing Dokuwiki. Of course, you can synchronize everything as you like. The wiki I used in my homepage is Dokuwiki. The most great feature is that it does not require database connection. It&#8217;s very convenience for personal usage. I have [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I will share my experience in synchronizing files with SSH here. Following are demonstrated by synchronizing Dokuwiki. Of course, you can synchronize everything as you like.</p>
<p>The <a href="http://chunhao.net/wiki/">wiki</a> I used in my homepage is <a href="http://www.dokuwiki.org/">Dokuwiki</a>. The most great feature is that it does not require database connection. It&#8217;s very convenience for personal usage.</p>
<p>I have two Dokuwiki maintained. One is located in localhost, another in the webserver. I always edit the pages on localhost, and synchronize them to the webserver at times. Since Dokuwiki is totally PHP based, without database such as MySQL, I only need to synchronize some files.</p>
<p>All the changes on wiki are reflected on the folder &#8220;data&#8221; in your Dokuwiki path. So every time, I only need to synchronize this folder.</p>
<p>The best way to communicate with webserver is SSH. Fortunately, my webserver <a href="https://www.godaddy.com/">Godaddy</a> support SSH access. Another thing need to concern is synchronizer. Here I use <a href="http://www.cis.upenn.edu/~bcpierce/unison/">Unison</a>. The best description of Unison comes from it&#8217;s the author of this software:</p>
<blockquote><p>A file-synchronization tool for Unix and Windows<br />
Unison is a file-synchronization tool for Unix and Windows, written<br />
in OCaml. It allows two replicas of a collection of files and<br />
directories to be stored on different hosts (or different disks<br />
on the same host), modified separately, and then brought up to<br />
date by propagating the changes in each replica to the other.</p>
<p>Unison offers several advantages over various synchronization methods<br />
such as CVS, Coda, rsync, Intellisync, etc. Unison can run on and<br />
synchronize between Windows and many UNIX platforms. Unison requires<br />
no root privileges, system access or kernel changes to function. Unison<br />
can synchronize changes to files and directories in both directions,<br />
on the same machine, or across a network using ssh or a direct<br />
socket connection.</p>
<p>Transfers are optimised using a version of the rsync protocol,<br />
making it ideal for slower links. Unison has a clear and precise<br />
specification, and is resilient to failure due to its careful<br />
handling of the replicas and its private structures.</p></blockquote>
<p>If you are using Ubuntu machine, you can install it from the repository just by one command:</p>
<blockquote><p>sudo apt-get install unison</p></blockquote>
<p>There is also a gtk front-end for this software: unison-gtk, but I think it&#8217;s useless at most time.</p>
<p>Now, another problem comes to front&#8211;in order to synchronize files with SSH, both installations of Unison on client and server are required. However, at most time, you don&#8217;t have the permission to install software such as unison on SSH server. Here, we attack this issue by SSHFS. It allows you to mount a remote folder on your machine via SSH.</p>
<p>Everything is OK. I wrote a small script to handle the synchronization:</p>
<pre lang="bash">#!/bin/sh
sshfs -o workaround=rename username@sshserver:/path/html/wiki wiki-remote/
echo "Synchronising with sshserver"
unison /var/www/dokuwiki/data ./wiki-remote/data 
  -fastcheck yes 
  -ignore 'Path cache' 
  -ignore 'Path locks'</pre>
<p>Modify it to fit your actual environment. Note that the argument of sshfs command &#8220;-o workaround=rename&#8221;, this prevents the &#8220;<a href="http://ubuntuforums.org/showthread.php?t=553103">renaming problem</a>&#8220;.</p>
<p>All things done. Excute this script. Or, you could add an cron job to run this script automatically once per day. Have fun in synchronizing files with SSH!</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/how-to-synchronize-with-ssh/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
