<?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>Piece of Unix Hints &#187; rsync</title>
	<atom:link href="http://hints.jeb.be/tag/rsync/feed/" rel="self" type="application/rss+xml" />
	<link>http://hints.jeb.be</link>
	<description>hints.jeb.be</description>
	<lastBuildDate>Fri, 04 Dec 2009 20:35:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Backup file of multiple user with rsync</title>
		<link>http://hints.jeb.be/2008/12/17/backup-file-of-multiple-user-with-rsync/</link>
		<comments>http://hints.jeb.be/2008/12/17/backup-file-of-multiple-user-with-rsync/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:52:07 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=40</guid>
		<description><![CDATA[root problem with rsync Imagine that you want to backup the /home directory of server &#8216;A&#8217; to server &#8216;B&#8217; using rsync. There is two way to do this : You can run rsync on the server &#8216;A&#8217;, but if you want to correctly backup (I mean, having correct uid/gid/.. on backuped files) files you should [...]]]></description>
			<content:encoded><![CDATA[<p><strong>root problem with rsync</strong></p>
<p>Imagine that you want to backup the /home directory of server &#8216;A&#8217; to server &#8216;B&#8217; using rsync.</p>
<p>There is two way to do this :</p>
<ul>
<li>You can run rsync on the server &#8216;A&#8217;, but if you want to correctly backup (I mean, having correct uid/gid/.. on backuped files) files you should connect to the server &#8216;B&#8217; as root. I&#8217;m sure you don&#8217;t want to do that.</li>
</ul>
<ul>
<li>You can run rsync on the server &#8216;B&#8217;, but you should connect to &#8216;A&#8217; with an user that can read all file in /home. This could be complicated depending of your gid managment.</li>
</ul>
<p><strong>When Tar start to be your best friend<br />
</strong><br />
So how can you do ? the solution would be to store (uid/gid/permission/..) information in a dedicated file, so that you can apply them if you need to restore data.<br />
How can you do that ? I&#8217;m sure you are too lazy to write a shell/perl/python/.. script to do that. You&#8217;re right ! Use tar.<br />
What ? What ? You want me to tar /home and rsync it ? Are you mad ? I don&#8217;t use rsync to transfer 20Go at each backup.</p>
<p><strong>When 1 option and 2 lines can save you<br />
</strong><br />
Tar as an incremental option. This mean that you can make a 1st tar file with /home then you can do a 2nd tar file with only modified file since previous tar. This option is -g.<br />
Here is a 2 lines shell script to do the job</p>
<pre>gtar -g /var/backup/home/home-backup.snar -cpvzf /var/backup/home/home-backup.`/bin/date +%s`.tgz /home/
rsync --delay-updates -avz -e ssh /var/backup/home backupuser@'B':/var/backup/</pre>
<p>&#8211;delay-updates is very important because if you don&#8217;t use it if &#8216;A&#8217; crash when rsync is copying the .snar file (used to store incrementation information) you will miss it on &#8216;B&#8217; and can&#8217;t retore tar file correctly.<br />
-g only exist in GNU Tar. You may have to install it if you&#8217;re running *BSD. First check if you have a gtar binnary</p>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/backup-file-of-multiple-user-with-rsync/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
