<?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>Libre Things &#187; rsync</title>
	<atom:link href="http://positon.org/tag/rsync/feed" rel="self" type="application/rss+xml" />
	<link>http://positon.org</link>
	<description></description>
	<lastBuildDate>Tue, 23 Feb 2016 20:01:11 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.7.1</generator>
	<item>
		<title>Clone a Linux system install to another computer</title>
		<link>http://positon.org/clone-a-linux-system-install-to-another-computer</link>
		<comments>http://positon.org/clone-a-linux-system-install-to-another-computer#comments</comments>
		<pubDate>Sun, 06 Apr 2014 15:54:06 +0000</pubDate>
		<dc:creator><![CDATA[dooblem]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gparted]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://positon.org/?p=159</guid>
		<description><![CDATA[After searching a bit I could not find a simple and good howto to do that. The following method should work for any Linux distribution (Ubuntu, Debian, Manjaro, Archlinux, Fedora&#8230;). Source and target systems must be on the same processor architecture (though transfer from 32bit to 64bit should work). What you need: 2 live USB [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>After searching a bit I could not find a simple and good howto to do that.<br />
The following method should work for any Linux distribution (Ubuntu, Debian, Manjaro, Archlinux, Fedora&#8230;). Source and target systems must be on the same processor architecture (though transfer from 32bit to 64bit should work).</p>
<p>What you need:</p>
<ul>
<li>2 live USB keys (or cds)</li>
<li>To speed up data transfer: good quality ethernet cables (one cable between the 2 computers is OK), or a usb key/drive with a BIG ext4 partition. You can try over wifi, but it may be slow.</li>
</ul>
<h3>1. Boot source and target machines on live USB/CD</h3>
<p>Any live USB/CD should be OK.<br />
On the target computer, you will need a tool to partition your hard drive, like <a href="http://gparted.org/" title="gparted">gparted</a>.<br />
<a href="http://rsync.samba.org/" title="rsync">rsync</a> is also required for data transfer: it&#8217;s included in many live systems.</p>
<p><a href="http://www.ubuntu.com/" title="Ubuntu">Ubuntu</a> live cd is OK, <a href="http://manjaro.org/" title="Manjaro">Manjaro</a> live cd too.</p>
<h3>2. Partition your target hard drive</h3>
<p>Use a tool like <a href="http://gparted.org/" title="gparted">gparted</a> to partition the target hard drive, with the same partitions as your source system (slash, swap, home&#8230;).<br />
I recommend you to assign LABELs to your partitions: for the fstab, it&#8217;s easier than UUIDs.</p>
<h3>3. Mount all partitions on both machines</h3>
<p>On both systems, open a root terminal. Then, for each data partition (you can ignore swap):</p>
<pre>
mkdir /mnt/slash
mount /dev/sdaX /mnt/slash
</pre>
<p>If you have a home partition:</p>
<pre>
mkdir /mnt/home
mount /dev/sdaY /mnt/home
</pre>
<h3>4. Transfer the data (network or usb)</h3>
<p>This part may be tricky. Choose the method you prefer.</p>
<h4>Network</h4>
<ol>
<li><strong>Setup the network.</strong> Test the connectivity with ping command.<br />
The easier is to plug the PCs on a DHCP network (like your ISP box) so that you get automatic IP addresses. If you linked the 2 pcs with a single cable, you&#8217;ll have to setup the IPs with NetworkManager (static ips, or adhoc network).</li>
<li>On source system, as root, create a simple <code>/etc/rsyncd.conf</code> file:
<pre>
uid = root
gid = root
use chroot = no

[all]
    path = /
</pre>
</li>
<li>Then start the rsync daemon server: <code>rsync --daemon</code></li>
<li>On target PC, for each partition:
<pre>
rsync -avHX SOURCE_IP::all/mnt/slash/ /mnt/slash/
</pre>
<p>Don&#8217;t forget &#8216;/&#8217; at the end of paths. <code>-a</code> will preserve many file attributes like owner and permissions, <code>-H</code> will preserve hardlinks if any, <code>-X</code> will preserve extended attributes like setuid. You may also add <code>-A</code> if you are using acls. What is good with rsync is that you can stop and restart the transfer whenever you want.
</li>
</ol>
<h4>USB</h4>
<p>Prepare a USB drive with a BIG ext4 partition.</p>
<ol>
<li>Mount the USB partition on source system (<code>mount /dev/sdbX /mnt/usb</code>)</li>
<li>For each partition:
<pre>
rsync -avHX /mnt/slash/ /mnt/usb/slash/
</pre>
</li>
<li>umount, unplug and remount the USB disk on the target system.</li>
<li>For each partition:
<pre>
rsync -avHX /mnt/usb/slash/ /mnt/slash/
</pre>
</li>
</ol>
<h3>5. Change fstab on target system</h3>
<p>As root, edit <code>/mnt/slash/etc/fstab</code><br />
For each partition (including swap), replace the first field with the new UUID or LABEL (it&#8217;s straightforward with LABELs):<br />
<code>UUID=the-long-uuid</code>, or <code>LABEL=yourlabel</code></p>
<p>2 ways to get the UUIDs / LABELs:</p>
<pre>
ls -l /dev/disk/by-uuid/
blkid /dev/sdaX
</pre>
<h3>6. Reinstall Grub</h3>
<p>We will use a <strong>chroot</strong> (changed root environment) to be able to call the <a href="http://www.gnu.org/software/grub/" title="Grub">grub</a> install inside the migrated system.</p>
<p>First, bind mount some system directories needed by grub, then chroot:</p>
<pre>
mount --bind /proc /mnt/slash/proc
mount --bind /sys /mnt/slash/sys
mount --bind /dev /mnt/slash/dev
mount --bind /run /mnt/slash/run
chroot /mnt/slash
</pre>
<p>Then install grub in the <a href="http://en.wikipedia.org/wiki/Master_boot_record" title="master boot record">Master Boot Record</a> of your hard drive, and update grub config file (with the new uuids&#8230;):</p>
<pre>
grub-install /dev/sda
update-grub
</pre>
<h3>7. Reboot target machine</h3>
<p>That&#8217;s it! Your system should be working on the new computer now.<br />
Feel free to comment if you encounter problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://positon.org/clone-a-linux-system-install-to-another-computer/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Bsync: Bidirectional Synchronization using Rsync</title>
		<link>http://positon.org/bsync-bidirectional-synchronization-using-rsync</link>
		<comments>http://positon.org/bsync-bidirectional-synchronization-using-rsync#comments</comments>
		<pubDate>Thu, 05 Dec 2013 22:22:36 +0000</pubDate>
		<dc:creator><![CDATA[dooblem]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bsync]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://fr.positon.org/?p=152</guid>
		<description><![CDATA[Bsync is a bidirectional file synchronization tool, using rsync for transfers. Moved files are also synchronized in a smart way. It uses rsync for file transfers, find to generate filelist snapshots, and ssh for remote transfers. bsync is an alternative to Unison, written in Python 3. A big strength of bsync: it can detect and [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Bsync is a bidirectional file synchronization tool, using rsync for transfers. <strong>Moved files</strong> are also synchronized in a smart way.</p>
<p>It uses <a href="http://rsync.samba.org">rsync</a> for file transfers, <a href="http://www.gnu.org/software/findutils/">find</a> to generate filelist snapshots, and <a href="http://www.openssh.com/">ssh</a> for remote transfers.</p>
<p>bsync is an alternative to Unison, written in <a href="http://www.python.org/">Python 3</a>. A big strength of bsync: it can detect and apply moved files from one side to the other (Unison uses some copy calls to handle moved files).</p>
<p>I developped it to be able to synchronize my music directory from my laptop to my <a href="http://www.raspberrypi.org/">Raspberry Pi</a> in an efficient way, and to sync with my girlfriend laptop too.</p>
<p>Bsync is released under GPL. Feel free to report any bugs/wishes in <a href="https://github.com/dooblem/bsync/issues">GitHub issues</a>.</p>
<p><a href="https://github.com/dooblem/bsync">More info, Download and Install on the GitHub repo.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://positon.org/bsync-bidirectional-synchronization-using-rsync/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Rsync command restriction over SSH</title>
		<link>http://positon.org/rsync-command-restriction-over-ssh</link>
		<comments>http://positon.org/rsync-command-restriction-over-ssh#comments</comments>
		<pubDate>Wed, 29 Dec 2010 17:36:00 +0000</pubDate>
		<dc:creator><![CDATA[dooblem]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://positon.org:81/?p=108</guid>
		<description><![CDATA[You have 2 systems and you want to set up a secure backup with rsync + SSH of one system to the other. Very simply, you can use: backup.example.com# rsync -avz --numeric-ids --delete root@myserver.example.com:/path/ /backup/myserver/ To do the backup, you have to be root on the remote server, because some files are only root readable. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>You have 2 systems and you want to set up a secure backup with rsync + SSH of one system to the other.</p>
<p>Very simply, you can use:</p>
<pre>
backup.example.com# rsync -avz --numeric-ids --delete root@myserver.example.com:/path/ /backup/myserver/
</pre>
<p>To do the backup, you have to be root on the remote server, because some files are only root readable.</p>
<p>Problem: you will allow backup.example.com to do anything on myserver.example.com, where just read only access on the directory is sufficient.</p>
<p>To solve it, you can use the <code>command=""</code> directive in the <code>authorized_keys</code> file to filter the command.</p>
<p>To find this command, start rsync adding the <code>-e'ssh -v'</code> option:</p>
<pre>
rsync -avz -e'ssh -v' --numeric-ids --delete root@myserver.example.com:/path/ /backup/myserver/ 2&gt;&amp;1 | grep &quot;Sending command&quot;
</pre>
<p>You get a result like:</p>
<pre>
debug1: Sending command: rsync --server --sender -vlogDtprze.iLsf --numeric-ids . /path/
</pre>
<p>Now, just add the command before the key in <code>/root/.ssh/authorized_keys</code>:</p>
<pre>
command=&quot;rsync --server --sender -vlogDtprze.iLsf --numeric-ids . /path/&quot; ssh-rsa AAAAB3NzaC1in2EAAAABIwAAABio......
</pre>
<p>And for even more security, you can add an IP filter, and other options:</p>
<pre>
from=&quot;backup.example.com&quot;,command=&quot;rsync --server --sender -vlogDtprze.iLsf --numeric-ids . /path/&quot;,no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-rsa AAAAB3NzaC1in2EAAAABIwAAABio......
</pre>
<p>Now try to open a ssh shell on the remote server.. and try some unauthorized rsync commands&#8230;</p>
<p>Notes:</p>
<ul>
<li>Beware that if you change rsync command options, change also the <code>authorized_keys</code> file.</li>
<li>No need for complex chroot anymore. Forget my previous article: <a href="/sftp-chroot-rsync">sftp-chroot-rsync</a></li>
</ul>
<p><ins>See also</ins>:</p>
<ul>
<li><code>man ssh #/AUTHORIZED_KEYS FILE FORMAT</code></li>
<li><code>man rsync</code></li>
<li><code>view /usr/share/doc/rsync/scripts/rrsync.gz</code> (restricted rsync, allows you to manage allowed options precisely)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://positon.org/rsync-command-restriction-over-ssh/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>SFTP chroot + rsync</title>
		<link>http://positon.org/sftp-chroot-rsync</link>
		<comments>http://positon.org/sftp-chroot-rsync#comments</comments>
		<pubDate>Fri, 09 Oct 2009 16:12:00 +0000</pubDate>
		<dc:creator><![CDATA[dooblem]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[chroot]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[SFTP]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://positon.org:81/?p=62</guid>
		<description><![CDATA[Here is howto make sftp shares with chroot. In /etc/ssh/sshd_config: # we use openssh internal sftp # because /usr/lib/openssh/sftp-server won't be available in chroot Subsystem sftp internal-sftp Match group sftp ChrootDirectory %h X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp UPDATE 17/06/2010: Beware with the syntax! Comments must start at the line beginning, and no spaces at [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Here is howto make sftp shares with chroot.</p>
<p>In <code>/etc/ssh/sshd_config</code>:</p>
<pre>
# we use openssh internal sftp
# because /usr/lib/openssh/sftp-server won't be available in chroot
Subsystem sftp internal-sftp

Match group sftp
        ChrootDirectory %h
        X11Forwarding no
        AllowTcpForwarding no
        ForceCommand internal-sftp
</pre>
<p><strong>UPDATE 17/06/2010:</strong> Beware with the syntax! Comments must start at the line beginning, and no spaces at the end of the <code>ForceCommand internal-sftp</code> line.</p>
<p>Now just create users belonging to sftp group, and that&#8217;s it.<br />
Test it with:</p>
<pre>
sftp user@myserver.com
</pre>
<p><strong>Problem: we cannot use the rsync command to send files</strong>, because rsync is not available in the chroot.</p>
<p>First, we allow other commands, commenting the line:</p>
<pre>
#ForceCommand internal-sftp
</pre>
<p>Then, we build the following tree in the chroot directory:</p>
<pre>
bin/
bin/bash
bin/rsync
lib/
lib/libncurses.so.5
lib/ld-linux.so.2
lib/libacl.so.1
lib/libpopt.so.0
lib/libattr.so.1
lib/i686
lib/i686/cmov
lib/i686/cmov/libdl.so.2
lib/i686/cmov/libc.so.6
</pre>
<p>We must put both <code>bash</code> and <code>rsync</code> commands, and all their librairies (you can display them with the <code>ldd</code> command).</p>
<p>Note: the user must have <code>/bin/bash</code> as default shell.</p>
<p>Note2: the chroot dir must belong to root, even if it&#8217;s the user&#8217;s folder. To allow the user to write in it, you have to create a subfolder with appropriate permissions. According to OpenSSH programers, it&#8217;s a big constraint, but very important for a chroot&#8217;s security.</p>
<p><ins>References</ins> :</p>
<ul>
<li><code>man sshd_config</code></li>
<li><a href="http://www.debian-administration.org/articles/590" title="http://www.debian-administration.org/articles/590">http://www.debian-administration.org/articles/590</a></li>
<li><a href="http://www.howtoforge.org/chrooted-ssh-sftp-tutorial-debian-lenny" title="http://www.howtoforge.org/chrooted-ssh-sftp-tutorial-debian-lenny">http://www.howtoforge.org/chrooted-ssh-sftp-tutorial-debian-lenny</a></li>
<li><a href="http://www.fuschlberger.net/programs/ssh-scp-sftp-chroot-jail/" title="http://www.fuschlberger.net/programs/ssh-scp-sftp-chroot-jail/">http://www.fuschlberger.net/programs/ssh-scp-sftp-chroot-jail/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://positon.org/sftp-chroot-rsync/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(Français) Sauvegarde intelligente avec rsync</title>
		<link>http://positon.org/sauvegarde-intelligente-avec-rsync</link>
		<comments>http://positon.org/sauvegarde-intelligente-avec-rsync#comments</comments>
		<pubDate>Tue, 29 Jul 2008 13:43:00 +0000</pubDate>
		<dc:creator><![CDATA[dooblem]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://positon.org:81/?p=35</guid>
		<description><![CDATA[Sorry, this entry is only available in Français.]]></description>
				<content:encoded><![CDATA[<p>Sorry, this entry is only available in <a href="http://fr.positon.org/tag/rsync/feed">Français</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://positon.org/sauvegarde-intelligente-avec-rsync/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
	</channel>
</rss>
