<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>How to back up a live rootfs using rsync</title>
        <description> I. INSTALLATION


A. Setup rsync to back up a live rootfs to a network backup server


A.1. Network Client side rsync 

This is where the rootfs is, while the system is running. 

1. Install rsync


apt-get install rsync

2. Download and copy the attached script rsync.backup.daily to root home folder 


cp -a rsync.backup.daily /root/rsync.backup.daily
chmod +x /root/rsync.backup.daily

3. Create the rsync password file. And secure it.


echo &amp;quot;mybackuppasswd&amp;quot; &amp;gt; /root/rsync.backup.daily.pswd
chmod 600 /root/rsync.backup.daily.pswd

4. Set up a cron job to run at 11:25 AM dailly

Install cron if not already installed

apt-get install cron
Edit the crontab

crontab -e
And add the following line at the end (or replace/modify if this time slot is already in the crontab)

25 11 * * * /root/rsync.backup.daily
List the cron jobs to doublecheck

crontab -l

5. Setup logrotate
 
Install logrotate if not already installed

apt-get install logrotate

Add the following section for rsync at the end of /etc/logrotate.conf 


/var/log/rsync.backup.daily.log {
    missingok
    size 256k
    su root root
    create 0660 root root
    rotate 4
    compress
}


A.2. Network Server side rsync

This is where the back up server is. 

1. Install rsync


apt-get install rsync


2. Enable rsync daemon at boot

Edit /etc/default/rsync to set enable flag to true


RSYNC_ENABLE=true

3. Download and copy the attached /etc/rsyncd.conf


cp -a rsyncd.conf /etc/rsyncd.conf

4. Create the rsync credential file. And secure it


echo &amp;quot;mybackup:mybackuppasswd&amp;quot; &amp;gt;  /etc/rsyncd.scrt
chmod 600 /etc/rsyncd.scrt

5.  Setup logrotate
 
Install logrotate if not already installed

apt-get install logrotate

Add the following section for rsync at the end of /etc/logrotate.conf 

/tmp/rsyncd.log {
    missingok
    size 256k
    su root root
    create 0660 root root
    rotate 8
    compress
}

6. Start rsync daemon


/etc/init.d/rsync start


B. Setup rsync to back up a live rootfs to a local USB drive

This section B is independent from section A above. Meaning there is no need to the whole set up as described in section A.1 and A.2 in order to do backup to USB.

1. Install rsync if not already installed


apt-get install rsync

2. Download and copy the attached script rsync.backup.ondemand to root home folder


cp -a rsync.backup.ondemand /root/rsync.backup.ondemand
chmod +x /root/rsync.backup.ondemand

3. Running on-demand backup

- Format a USB drive with Ext3 (Ext4 is OK if uboot on the rootfs box can recognize it)
- Label it with something meaningful, e.g. BackupRootfs

3.1 Mount the USB backup drive to /media. This is required so that we can avoid mistake in being at the wrong place.

3.2 Start the back up from the USB drive


cd /media/BackupRootfs
/root/rsync.backup.ondemand &amp;amp;

From now on the rsync will do incremental backup to the USB when we run the back up commands above (steps 3.1 and 3.2).

Note: 

TBD - this process will be customized further to make the script run automatically whenever the backup USB drive is inserted. 


II. Glossary

/root/rsync.backup.daily
The main script. Scheduled by cron

/etc/rsyncd.conf
The rsync conf file for the backup server (used by rsync daemon)

/root/rsync.backup.daily.pswd
The password file that rsync uses to authenticate the client backup job with the backup server.

/etc/rsyncd.scrt
The credential file that rsync on the with the backup server side uses to authenticate the client backup request. 

/root/rsync.backup.ondemand
The on-demand script. Back up the rootfs to a USB drive.


/var/log/rsync.backup.daily.log
The client side log file

/tmp/rsyncd.log
The backup server side log file

=====================

Updated 01 Jan 2023 

I&amp;#039;ve updated the script rsync.backup.ondemand to make it a bit more robust. I&amp;#039;m making sure the USB can be used as the rootfs and a boot drive.</description>
        <link>https://forum.doozan.com/read.php?2,111249,111249#msg-111249</link>
        <lastBuildDate>Wed, 11 Mar 2026 09:11:16 -0500</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,133782#msg-133782</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,133782#msg-133782</link>
            <description><![CDATA[ <b>Updated 01 Jan 2023</b> <br />
<br />
I&#039;ve updated the script rsync.backup.ondemand to make it a bit more robust. I&#039;m making sure the USB can be used as the rootfs and a boot drive.]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Sun, 01 Jan 2023 17:16:51 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,116814#msg-116814</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,116814#msg-116814</link>
            <description><![CDATA[ FYI,<br />
<br />
I&#039;ve done with the tutorial in the 1st post.]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Sun, 21 Feb 2021 16:50:44 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,112099#msg-112099</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,112099#msg-112099</link>
            <description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>If you writing code or scripts, you should really be using version control such as git or svn. And rsync backup daily using this process.</strong><br />
</div></blockquote>
<br />
only toying with a few scripts thus far, kinda new to that. actually been trying a little bit of anything to see what this device can do then if I like it i incorporate it to my main plug which right now is mostly a home server. I may try git or svn later when I can dedicate more time to it:)]]></description>
            <dc:creator>echowarrior108</dc:creator>
            <category>Debian</category>
            <pubDate>Mon, 30 Nov 2020 22:39:16 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,112094#msg-112094</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,112094#msg-112094</link>
            <description><![CDATA[ &gt; I can&#039;t tell you how many times I used to start<br />
&gt; all over with programming because of this or<br />
&gt; that.... I used to dd copy every so often then<br />
&gt; remove the copied usb which is effective to a<br />
&gt; certain extent however this is a much better way<br />
&gt; for sure!<br />
<br />
If you writing code or scripts, you should really be using version control such as git or svn. And rsync backup daily using this process.]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Mon, 30 Nov 2020 18:17:46 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,112079#msg-112079</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,112079#msg-112079</link>
            <description><![CDATA[ I can&#039;t tell you how many times I used to start all over with programming because of this or that.... I used to dd copy every so often then remove the copied usb which is effective to a certain extent however this is a much better way for sure!]]></description>
            <dc:creator>echowarrior108</dc:creator>
            <category>Debian</category>
            <pubDate>Mon, 30 Nov 2020 03:16:53 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,112074#msg-112074</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,112074#msg-112074</link>
            <description><![CDATA[ &gt; I did find a little shortcut to watching by using<br />
&gt; htop.I use a second terminal then simply run htop,<br />
&gt; what I do then is hit f4 for search and type in<br />
&gt; rsync and anything running rsync will show as it<br />
&gt; runs. What is nice is that it shows how much<br />
&gt; memory is being used at the same time.<br />
<br />
Yes, it is a handy way to see what&#039;s going on!<br />
<br />
This rsync setup has saved my ass a few times :)) the key is don&#039;t do --detete for a daily backup. Once in a while, you would turn on --delete to get rid of old files in the backup server.  When it happens that you accidentally delete some file because of fat fingers or just sleepy, or tipsy, you can just restore that file from the backup server immediately :)]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Mon, 30 Nov 2020 00:19:15 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,112069#msg-112069</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,112069#msg-112069</link>
            <description><![CDATA[ I did find a little shortcut to watching by using htop.I use a second terminal then simply run htop, what I do then is hit f4 for search and type in rsync and anything running rsync will show as it runs. What is nice is that it shows how much memory is being used at the same time.<br />
<br />
It was massive on the first try for sure! it goes fast now. <br />
<br />
currently I am running an ssd on the sata drive and rsynking to usb as described so I am sure it is a bit faster than most but I will be trying out on my mpcie drive device soon which will take a bit longer.]]></description>
            <dc:creator>echowarrior108</dc:creator>
            <category>Debian</category>
            <pubDate>Sun, 29 Nov 2020 23:37:44 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,112064#msg-112064</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,112064#msg-112064</link>
            <description><![CDATA[ echowarrior108 Wrote:<br />
-------------------------------------------------------<br />
&gt; see I missed it lol<br />
<br />
<br />
:) the first time you do back up it will be massive (logrotate will eventually compress it). From now own the log will be smaller.]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Sun, 29 Nov 2020 18:53:06 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,112059#msg-112059</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,112059#msg-112059</link>
            <description><![CDATA[ see I missed it lol]]></description>
            <dc:creator>echowarrior108</dc:creator>
            <category>Debian</category>
            <pubDate>Sun, 29 Nov 2020 17:00:36 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,112049#msg-112049</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,112049#msg-112049</link>
            <description><![CDATA[ echowarrior108,<br />
<br />
&gt; is there a way to show progress while running or<br />
&gt; did I miss something?<br />
<br />
That&#039;s part of what I need to describe in Section II.<br />
<br />
The log you can monitor is in the rsync command.<br />
<pre class="bbcode">
/var/log/rsync.backup.daily.log
/tmp/rsync.backup.daily.log</pre>
<br />
And in the backup server, <br />
<br />
<pre class="bbcode">
/tmp/rsyncd.log
</pre>]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Sun, 29 Nov 2020 15:31:22 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,112034#msg-112034</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,112034#msg-112034</link>
            <description><![CDATA[ bodhi, good work, here was how my rsync.backup.on demand looked on my pogoplug pro v3 test device<br />
<br />
<pre class="bbcode">
/media/USB# /root/rsync.backup.ondemand
&lt;13&gt;Nov 29 15:09:33 root[12560]: Started rsync on-demand backup for ppdebian
&lt;13&gt;Nov 29 15:28:46 root[12683]: Finished rsync on-demand backup for ppdebian</pre>
<br />
<br />
is there a way to show progress while running or did I miss something?]]></description>
            <dc:creator>echowarrior108</dc:creator>
            <category>Debian</category>
            <pubDate>Sun, 29 Nov 2020 14:33:19 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,111909#msg-111909</guid>
            <title>Re: How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,111909#msg-111909</link>
            <description><![CDATA[ This tutorial is almost done. I just need to explain a few things, i.e. what names to change, etc.<br />
<br />
 It can be used now by experience users who know how to customize the set up for their own configurtion.]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Fri, 27 Nov 2020 18:22:16 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,111354#msg-111354</guid>
            <title>Re: rsync - How to setup rsync job to back up a live rootfs</title>
            <link>https://forum.doozan.com/read.php?2,111249,111354#msg-111354</link>
            <description><![CDATA[ Feel free to ask questions while I am modifying the 1st post (you might have done research before about this subject).<br />
<br />
The set up is a little bit tedious, especially the rsync syntax is tricky.]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Thu, 19 Nov 2020 22:51:08 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,111349#msg-111349</guid>
            <title>Re: rsync - How to setup rsync job to back up a live rootfs</title>
            <link>https://forum.doozan.com/read.php?2,111249,111349#msg-111349</link>
            <description><![CDATA[ Looking forward to this.  It&#039;s something I&#039;ve wanted to look into for a while now to handle the remote units I take care of.]]></description>
            <dc:creator>renojim</dc:creator>
            <category>Debian</category>
            <pubDate>Thu, 19 Nov 2020 21:41:44 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,111324#msg-111324</guid>
            <title>Re: rsync - How to setup rsync job to back up a live rootfs</title>
            <link>https://forum.doozan.com/read.php?2,111249,111324#msg-111324</link>
            <description><![CDATA[ LeggoMyEggo Wrote:<br />
-------------------------------------------------------<br />
&gt; Backed up and compressed I assume.<br />
<br />
rsync compress the files to save bandwith while sending. However,  the backup area is an uncompressed folder ( a mirror of the source folder / ).]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Thu, 19 Nov 2020 16:53:40 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,111314#msg-111314</guid>
            <title>Re: rsync - How to setup rsync job to back up a live rootfs</title>
            <link>https://forum.doozan.com/read.php?2,111249,111314#msg-111314</link>
            <description><![CDATA[ Backed up and compressed I assume.]]></description>
            <dc:creator>LeggoMyEggo</dc:creator>
            <category>Debian</category>
            <pubDate>Thu, 19 Nov 2020 07:53:30 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,111304#msg-111304</guid>
            <title>Re: rsync - How to setup rsync job to back up a live rootfs</title>
            <link>https://forum.doozan.com/read.php?2,111249,111304#msg-111304</link>
            <description><![CDATA[ :thumbsup!]]></description>
            <dc:creator>Gravelrash</dc:creator>
            <category>Debian</category>
            <pubDate>Thu, 19 Nov 2020 03:37:11 -0600</pubDate>
        </item>
        <item>
            <guid>https://forum.doozan.com/read.php?2,111249,111249#msg-111249</guid>
            <title>How to back up a live rootfs using rsync</title>
            <link>https://forum.doozan.com/read.php?2,111249,111249#msg-111249</link>
            <description><![CDATA[ <b><span style="color:#0033FF">I. INSTALLATION</span></b><br />
<br />
<br />
<b><span style="color:#0033FF">A. Setup rsync to back up a live rootfs to a network backup server</span></b><br />
<br />
<br />
<span style="color:#0033FF"><b>A.1. Network Client side rsync </b></span><br />
<br />
This is where the rootfs is, while the system is running. <br />
<br />
1. Install rsync<br />
<br />
<pre class="bbcode">
apt-get install rsync</pre>
<br />
2. Download and copy the attached script rsync.backup.daily to root home folder <br />
<br />
<pre class="bbcode">
cp -a rsync.backup.daily /root/rsync.backup.daily
chmod +x /root/rsync.backup.daily</pre>
<br />
3. Create the rsync password file. And secure it.<br />
<br />
<pre class="bbcode">
echo &quot;mybackuppasswd&quot; &gt; /root/rsync.backup.daily.pswd
chmod 600 /root/rsync.backup.daily.pswd</pre>
<br />
4. Set up a cron job to run at 11:25 AM dailly<br />
<br />
Install cron if not already installed<br />
<pre class="bbcode">
apt-get install cron</pre>
Edit the crontab<br />
<pre class="bbcode">
crontab -e</pre>
And add the following line at the end (or replace/modify if this time slot is already in the crontab)<br />
<pre class="bbcode">
25 11 * * * /root/rsync.backup.daily</pre>
List the cron jobs to doublecheck<br />
<pre class="bbcode">
crontab -l</pre>
<br />
5. Setup logrotate<br />
 <br />
Install logrotate if not already installed<br />
<pre class="bbcode">
apt-get install logrotate</pre>
<br />
Add the following section for rsync at the end of /etc/logrotate.conf <br />
<br />
<pre class="bbcode">
/var/log/rsync.backup.daily.log {
    missingok
    size 256k
    su root root
    create 0660 root root
    rotate 4
    compress
}</pre>
<br />
<br />
<span style="color:#0033FF"><b>A.2. Network Server side rsync</b></span><br />
<br />
This is where the back up server is. <br />
<br />
1. Install rsync<br />
<br />
<pre class="bbcode">
apt-get install rsync</pre>
<br />
<br />
2. Enable rsync daemon at boot<br />
<br />
Edit /etc/default/rsync to set enable flag to true<br />
<br />
<pre class="bbcode">
RSYNC_ENABLE=true</pre>
<br />
3. Download and copy the attached /etc/rsyncd.conf<br />
<br />
<pre class="bbcode">
cp -a rsyncd.conf /etc/rsyncd.conf</pre>
<br />
4. Create the rsync credential file. And secure it<br />
<br />
<pre class="bbcode">
echo &quot;mybackup:mybackuppasswd&quot; &gt;  /etc/rsyncd.scrt
chmod 600 /etc/rsyncd.scrt</pre>
<br />
5.  Setup logrotate<br />
 <br />
Install logrotate if not already installed<br />
<pre class="bbcode">
apt-get install logrotate</pre>
<br />
Add the following section for rsync at the end of /etc/logrotate.conf <br />
<pre class="bbcode">
/tmp/rsyncd.log {
    missingok
    size 256k
    su root root
    create 0660 root root
    rotate 8
    compress
}</pre>
<br />
6. Start rsync daemon<br />
<br />
<pre class="bbcode">
/etc/init.d/rsync start</pre>
<br />
<br />
<b><span style="color:#0033FF">B. Setup rsync to back up a live rootfs to a local USB drive</span></b><br />
<br />
This section B is independent from section A above. Meaning there is no need to the whole set up as described in section A.1 and A.2 in order to do backup to USB.<br />
<br />
1. Install rsync if not already installed<br />
<br />
<pre class="bbcode">
apt-get install rsync</pre>
<br />
2. Download and copy the attached script rsync.backup.ondemand to root home folder<br />
<br />
<pre class="bbcode">
cp -a rsync.backup.ondemand /root/rsync.backup.ondemand
chmod +x /root/rsync.backup.ondemand</pre>
<br />
3. Running on-demand backup<br />
<br />
- Format a USB drive with Ext3 (Ext4 is OK if uboot on the rootfs box can recognize it)<br />
- Label it with something meaningful, e.g. BackupRootfs<br />
<br />
3.1 Mount the USB backup drive to /media. This is required so that we can avoid mistake in being at the wrong place.<br />
<br />
3.2 Start the back up from the USB drive<br />
<br />
<pre class="bbcode">
cd /media/BackupRootfs
/root/rsync.backup.ondemand &amp;</pre>
<br />
From now on the rsync will do incremental backup to the USB when we run the back up commands above (steps 3.1 and 3.2).<br />
<br />
<b><span style="color:#0033FF">Note</span></b>: <br />
<br />
<span style="color:#FF0000">TBD</span> - this process will be customized further to make the script run automatically whenever the backup USB drive is inserted. <br />
<br />
<br />
<b><span style="color:#0033FF">II. Glossary</span></b><br />
<br />
/root/rsync.backup.daily<br />
The main script. Scheduled by cron<br />
<br />
/etc/rsyncd.conf<br />
The rsync conf file for the backup server (used by rsync daemon)<br />
<br />
/root/rsync.backup.daily.pswd<br />
The password file that rsync uses to authenticate the client backup job with the backup server.<br />
<br />
/etc/rsyncd.scrt<br />
The credential file that rsync on the with the backup server side uses to authenticate the client backup request. <br />
<br />
/root/rsync.backup.ondemand<br />
The on-demand script. Back up the rootfs to a USB drive.<br />
<br />
<br />
/var/log/rsync.backup.daily.log<br />
The client side log file<br />
<br />
/tmp/rsyncd.log<br />
The backup server side log file<br />
<br />
=====================<br />
<br />
<b>Updated 01 Jan 2023</b> <br />
<br />
I&#039;ve updated the script <i>rsync.backup.ondemand</i> to make it a bit more robust. I&#039;m making sure the USB can be used as the rootfs and a boot drive.]]></description>
            <dc:creator>bodhi</dc:creator>
            <category>Debian</category>
            <pubDate>Wed, 18 Nov 2020 16:34:38 -0600</pubDate>
        </item>
    </channel>
</rss>
