Welcome! Log In Create A New Profile

Advanced

How to back up a live rootfs using rsync

Posted by bodhi 
How to back up a live rootfs using rsync
November 18, 2020 04:34PM
I am almost done on this tutorial.

===================================================================================

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 "mybackuppasswd" > /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 "mybackup:mybackuppasswd" >  /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


II. Customization and Operation

TBD.

/root/rsync.backup.daily
/etc/rsyncd.conf
/root/rsync.backup.daily.pswd
/etc/rsyncd.scrt
/root/rsync.backup.ondemand

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 13 time(s). Last edit at 11/22/2020 05:03PM by bodhi.
Attachments:
open | download - rsync.backup.ondemand (1.5 KB)
open | download - rsync.backup.daily (1.5 KB)
open | download - rsyncd.conf (373 bytes)
Re: rsync - How to setup rsync job to back up a live rootfs
November 19, 2020 03:37AM
:thumbsup!
Re: rsync - How to setup rsync job to back up a live rootfs
November 19, 2020 07:53AM
Backed up and compressed I assume.
Re: rsync - How to setup rsync job to back up a live rootfs
November 19, 2020 04:53PM
LeggoMyEggo Wrote:
-------------------------------------------------------
> Backed up and compressed I assume.

rsync compress the files to save bandwith while sending. However, the backup area is an uncompressed folder ( a mirror of the source folder / ).

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: rsync - How to setup rsync job to back up a live rootfs
November 19, 2020 09:41PM
Looking forward to this. It's something I've wanted to look into for a while now to handle the remote units I take care of.
Re: rsync - How to setup rsync job to back up a live rootfs
November 19, 2020 10:51PM
Feel free to ask questions while I am modifying the 1st post (you might have done research before about this subject).

The set up is a little bit tedious, especially the rsync syntax is tricky.

-bodhi
===========================
Forum Wiki
bodhi's corner
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: