Learning how to Back up a Raspberry Pi using rsync

As I started to develop on a Raspberry Pi under Raspbian I needed to find a way to back up the system I’m working on.

I will try to set up this using the linux command rsync.

Install rsync

If not yet installed just run this command:

Set up File to Exclude Directories not Needed

Excluded from a backup should be (* will have those directories created on the target media but kept empty):

Name this file rsync-exclude.txt and put it in a directory you might call backup in your /home/pi directory.

Using rsync Manually

For now I want to run rsync manually from a remote Computer via ssh as I am still in development and want to manually keep track of my snap shots.

The basic rsync syntax is:

The option -a takes care that all rights and users are transferred to the target medium.

To backup my Pi that I access by SSH from remote to an attached USB storage I use this command:

Make sure that you have mounted the USB device before to /mnt by the following commands.

Find out your devices’ name:

You will find something like /dev/sdb1 as the name of your device. Then mount it using that name:

 

Resources I’ve Been Using to Learn This:

http://raspberrypi.stackexchange.com/questions/5427/can-a-raspberry-pi-be-used-to-create-a-backup-of-itself/5492#5492

https://www.tutorialspoint.com/articles/how-to-mount-usb-drive-in-a-linux-system

http://www.liquidweb.com/kb/how-to-securely-transfer-files-via-rsync-and-ssh-on-linux/

in German: https://wiki.ubuntuusers.de/rsync/

Leave a Reply

Your email address will not be published. Required fields are marked *

twenty − 8 =