<?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>Felipe Alfaro Solana &#187; Rsync</title>
	<atom:link href="http://www.felipe-alfaro.org/blog/category/rsync/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.felipe-alfaro.org/blog</link>
	<description>A little bit of technology, security and networking with Linux, FreeBSD and Mac OS X, plus some personal opinions.</description>
	<lastBuildDate>Sun, 23 Oct 2011 16:46:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Amazon S3? Not yet ready for me!</title>
		<link>http://www.felipe-alfaro.org/blog/2009/03/15/amazon-s3-not-yet-ready-for-me/</link>
		<comments>http://www.felipe-alfaro.org/blog/2009/03/15/amazon-s3-not-yet-ready-for-me/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 17:44:01 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Rsync]]></category>

		<guid isPermaLink="false">http://www.felipe-alfaro.org/blog/?p=279</guid>
		<description><![CDATA[I&#8217;ve been thinking for a while how to properly keep back-ups of all of my data while, at the same time, saving a few bucks. Since the &#8220;cloud computing&#8221; term is now floating all over the Internet, I thought that a distributed, remote back-up service might do the work for me. I looked around and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking for a while how to properly keep back-ups of all of my data while, at the same time, saving a few bucks. Since the &#8220;cloud computing&#8221; term is now floating all over the Internet, I thought that a distributed, remote back-up service might do the work for me.</p>
<p>I looked around and found quite different services, but most of them offer ridiculously small storage size, like 5GB, or force me into using sub-par Web-based user interfaces that make using <a href="http://samba.anu.edu.au/rsync/">rsync</a> complicated or unfeasible. I&#8217;m looking services that offer 2TB+ storage and, so far, the only solution that I find promising is Amazon S3. The problem is price. Keeping 2,048GB of data stored in Amazon S3 costs me about $300 USD per month, plus a one-time cost for uploading the data. At that price, for a whole year, I can buy a QNAP TS-809 filled with 8 x 1.5TB disks <img src='http://www.felipe-alfaro.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So, unfortunately for me, multi-terabyte back-up copies to the Internet are still to expensive. Perhaps, in 5 years, technology will drive prices down such as that I can afford to keep my back-ups on the Internet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2009/03/15/amazon-s3-not-yet-ready-for-me/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Incremental backups with rsync</title>
		<link>http://www.felipe-alfaro.org/blog/2005/09/09/incremental-backups-with-rsync/</link>
		<comments>http://www.felipe-alfaro.org/blog/2005/09/09/incremental-backups-with-rsync/#comments</comments>
		<pubDate>Fri, 09 Sep 2005 02:01:59 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Rsync]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/?p=57</guid>
		<description><![CDATA[I have been thinking for a while to implement incremental, cyclical backups on my home network. The problem with cyclical backups to tape is that they are slow. The problem with cyclical backups to disk is that they consume a great deal of space. I finally opted for cyclical backups to disk since my DDS-3 [...]]]></description>
			<content:encoded><![CDATA[<p>I have been thinking for a while to implement incremental, cyclical backups on my home network. The problem with cyclical backups to tape is that they are slow. The problem with cyclical backups to disk is that they consume a great deal of space. I finally opted for cyclical backups to disk since my DDS-3 SCSI tape is slow and can&#8217;t hold the many gigabytes I have in data, even with hardware/software compression.</p>
<p>I want to periodically branch my main backup tree so that I can keep several backups, ordered from the newest (backup.0) to the oldest (backup.n), where &#8220;n&#8221; could be the number of days or weeks, depending on the frequency of the backups.</p>
<p>The filesystem should look like this:</p>
<pre>\-- backup.0
 |
 |- backup.1
 |
 |- backup.2
 |
 .
 .
 .
 \- backup.n</pre>
<p>A simple way to reduce disk space usage is by using a UNIX-like feature called hard-links. The idea behind this is that if a file does not see its contents changed between backups, we could save space by having all the identical copies hard-linked together.</p>
<p>Using <b>rsync</b> and <b>cp</b> we can implement this very easily, thanks to the way that <em>rsync</em> works. By default, when not using the <em>&#8211;inplace</em> command-line switch, if <em>rsync</em> detects that a destination file is different from its source file, instead of performing direct modifications onto the destination file by opening it, writing to it, then closing it, <em>rsync</em> will create a new file. This has several advantages:</p>
<ol>
<li>Users can keep on working with files, even when <em>rsync</em> is synching them underneath. Since <em>rsync</em> always creates a new file instead of performing modifications to the current file, users won&#8217;t suffer from the strangeness that involves multiple updates to the same file by multiple users/processes.</li>
<li>Since <em>rsync</em> creates a new file, when the original destination file is hard-linked across several backup branches, the synching process won&#8217;t indirectly sync up those backup branches too. Instead, they will be kept intact, and a new destination file, mirroring its source file, will be created.
<p>We don&#8217;t want that an update to a file in the backup.0 branch means updating any file hard-linked to it, since that would destroy the incremental semantics.</li>
</ol>
<p>Thus, we can implement a really simple cyclical backup scheme using <em>rsync</em> and hard-links..</p>
<ol>
<li>
<h4>Things to run on the server.</h4>
<p>We run this periodically:</p>
<pre># rm -fr backup.${n}
# for i in `seq ${n} -1 2`; do mv backup.$[${i}-1] backup.${i}; done
# cp -al backup.0 backup.1</pre>
<p>This will rotate all the backups, discarding the last one. Then, the <b>cp</b> command will replicate the main branch (<b>backup.0</b>) into (<b>backup.1</b>) by using hard-links.</p>
<p><b>NOTE for FreeBSD users:</b> the <em>cp</em> command that comes with the FreeBSD base system does not support neither the <em>-a</em> nor the <em>-l</em> command-line switches. <em>-a</em> means <em>-dpR</em> (recursively copy and preserve attributes), while <em>-l</em> means not to copy, but to create hard-links instead.</p>
<p>Fortunately, the FreeBSD ports collection includes a port of the GNU coreutils package, which sports the full <em>GNU cp</em> program, supporting the <em>-a</em> and <em>-l</em> switches:</p>
<pre># cd /usr/ports/sysutils/coreutils
# make all install</pre>
<p>To avoid the name clashing betweeh the <em>cp</em> command from the FreeBSD system and the GNU one, the GNU <em>cp</em> command is renamed to <b>gcp</b>. So, in the script listed bedore, we should rename the invocation to <em>cp</em> to <em>gcp</em>.</li>
<li>
<h4>Things to run on the client.</h4>
<p>To perform the incremental backup against the server, we can run the following command:</p>
<pre># rsync -a -E Users/ rsync://<rsync -server>:/data/backup.0/</rsync></pre>
<p>It&#8217;s very important to keep the timestamps synchronized on both the client and the server so rsync can use them to decide which files have been changed and which files not. This is done with the <b>-t</b> command-line switch. Note that the <b>-a</b> (archive) command-line switch to <em>rsync</em> is like specifying <em>-rlptgoD</em>, and thus we don&#8217;t have to specify <em>-t</em>.</p>
<p>The <b>-E</b> command-line switch is useful for Mac OS X-based machines and will allow synching files stored in a HFS+ volume that uses resource forks by using the AppleDouble format.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2005/09/09/incremental-backups-with-rsync/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adding extended attributes support to rsync</title>
		<link>http://www.felipe-alfaro.org/blog/2005/09/09/addind-extended-attributes-support-to-rsync/</link>
		<comments>http://www.felipe-alfaro.org/blog/2005/09/09/addind-extended-attributes-support-to-rsync/#comments</comments>
		<pubDate>Fri, 09 Sep 2005 00:47:49 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Rsync]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/?p=56</guid>
		<description><![CDATA[The rsync software that comes with Mac OS X 10.4, and newer releases, supports extended attributes (HFS+ resource forks). This means it can sync files from a local HFS+ filesystem to a remote volume which does not suport HFS+ resource forks by using AppleDouble encoding. The AppleDouble encoding splits a native HFS+ file in two [...]]]></description>
			<content:encoded><![CDATA[<p>The <em>rsync</em> software that comes with Mac OS X 10.4, and newer releases, supports extended attributes (HFS+ resource forks). This means it can sync files from a local HFS+ filesystem to a remote volume which does not suport HFS+ resource forks by using <a href="http://kb.iu.edu/data/aemi.html" title="AppleSingle and AppleDouble">AppleDouble</a> encoding.</p>
<p>The <b>AppleDouble</b> encoding splits a native HFS+ file in two parts:</p>
<ol>
<li>The <b>data fork</b>, which is the one that holds the real contents of the file, like the contents of a document, the pixels from a bitmap, and so on. It receives the same name as the original HFS+ file.</li>
<li>The <b>resource fork</b>, which is built of data held on the resource forks and Finder data, like the Spotlight comments and so on. It receives a filename which consists on prepending a dot and a slash characters to the original HFS+ filename.</li>
</ol>
<p>Thus, for a HFS+ file named <em>MyDocument.webloc</em>, when stored in the AppleDouble format, it is splitted in two files: <em>MyDocument.webloc</em> and <em>._MyDocument.webloc</em>.</p>
<p>By default, Mac OS X <em>rsync</em> implementation does not enable extended attributes support. This must be explicitly enabled by supplying the <b>-E</b> command-line switch to the <b>rsync</b> command. The problem is, however, that few <em>rsync</em> implementations (I don&#8217;t know of any besides Apple&#8217;s Mac OS X 10.4 one) support neither this kind of functionality nor the command-line switch that activates it.</p>
<p>The solution was pretty easy, by the way. I downloaded Darwin rsync source code for the <a title="Darwin rsync" href="http://www.opensource.apple.com/darwinsource/tarballs/other/rsync-20.tar.gz">rsync-20</a> from the <a title="Darwin Projects Directory" href="http://www.opensource.apple.com/darwinsource/10.4.2">Darwin Projects Directory</a> and extracted the file <b>patches/EA.diff</b> from within it. This patch file includes the extended attributes (HFS+ resource forks) functionality I was seeking. This patch, at the moment of this writing, is agaist <em>rsync-2.6.3</em>.</p>
<p>Thus, I only had to grab the sources for <em>rsync-2.6.3</em>, which are also included inside the <em>rsync-20.tar.gz</em> file I downloaded before, extracted them, patched, configured, made and installed:</p>
<pre>
<div># tar zxvf rsync-20.tar.gz
# cd rsync-20
# tar zxvf rsync-2.6.3.tar.gz
# cd rsync-2.6.3
# patch < ../patches/EA.diff
# CFLAGS="-O -pipe" \
  ./configure --prefix=/usr/local \
              --disable-debug --enable-ea-support \
               --with-rsyncd-conf=/usr/local/etc/rsyncd.conf
# make
# make install</div>
</div>
</pre>
<p>I ran the previous commands on <b>FreeBSD 7.0-CURRENT</b>, thus the <em>/usr/local</em> prefix. Also, note the <b>&#8211;enable-ea-support</b> command-line switch supplied to configure. It is required in order to build the extended attributes support in. Leaving it out will produce a normal, EA-disabled <em>rsync</em>.</p>
<pre># rsync --help | grep -- -E
 -E, --extended-attributes   copy extended attributes</pre>
<p>That&#8217;s all, folks. <img src='http://www.felipe-alfaro.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2005/09/09/addind-extended-attributes-support-to-rsync/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

