RPi Backup Machine

HowTo


Parts

1 x RPi 3 with a raspbian image (Lite will do)
1 x Portable Drive
1 x Y cable
1 x 5v 2A power supply
1 x Power cord for the RPi
Ethernet (or wireless) connection)

Setup

It is assumed you have set the RPi up before a all is working.

1. Connect it all up and switch it on
Backup machine

2. Find its IP address
3. ssh into your RPi
# ssh pi@192.168.0.34 or whatever. Give password if necessary
4. Use the mount command to make sure the portable HDD is mounted
5. # sudo mkdir /portable (or whatever you wish to call it)
6. # sudo chown -R pi:pi /portable so that the directory is writeable by user pi
7. Do a # blkid
Here is the result of a blkid on my RPi
/dev/mmcblk0p1: LABEL="boot" UUID="95E0-9AC4" TYPE="vfat" PARTUUID="229c6ea0-01"
/dev/mmcblk0p2: UUID="b105f9a8-f450-4976-8ac8-69053f57bab4" TYPE="ext4" PARTUUID="229c6ea0-02"
/dev/sda1: UUID="d7d26323-c6d4-4a8f-bad1-641c33eeb25e" TYPE="ext4" PARTUUID="483494d2-01

As you can see from the above, I had formatted the drive as ext4. Now what you want is the "ARTUUID="483494d2-01" of the portable drive.

FSTAB

As sudo, you need to edit the /etc/fstab file. # sudo nano /etc/fstab
Mine ended up looking like this, note the drive is mounted of the previously created /portable directory

==============================================================
proc /proc proc defaults 0 0
PARTUUID=229c6ea0-01 /boot vfat defaults 0 2
PARTUUID=229c6ea0-02 / ext4 defaults,noatime 0 1
PARTUUID=483494d2-01 /portable ext4 defaults 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
==============================================================

Check

Reboot the RPi and ssh back in and make sure your portable hard drive is on /portable

I use rsync to backup my home folder

rsync -avr --safe-links --exclude "Downloads/" --exclude ".local/share/Trash/" --exclude ".config/" --exclude ".cache/" --delete /home/owen pi@10.1.1.103:/portable/