Home Backups System

Backups, that "thing" I need but keeps being neglected. When I actually try to make frequent backups, it ends up being in such an unstructured manner that if I need a restore... well it's a challenge...

The time came where I said: "Enough is enough! I'm doing something about backups." I wanted something:

  • Automatic
  • Resilient and robust
  • Easy to use
  • Scalable
  • Not expensive

Considering myself a "Maker" I had to built my own system, obviously, instead of buying a market solution. So I started by getting the base platform, which was easy as I had a Raspberry Pi (going forward let's call it Raspi) at hand waiting for a project.

Next step was getting the storage. I opted for external USB disk drives, not the fancy SSD stuff just the plain old less expensive mechanical magnetic drives. This was basically it for core the hardware. Now I could start the assembly of my prototype.

Now for the "soft" stuff. I had some traumatic experiences with RAID type of storage setups, so this time I opted for simple incremental images direct to the disks drives. 

The flow in my mind was simple: 

  • Backups Level 1 - PCs to HDD 1
  • Backup Level 2 - HDD 1 to HDD 2

In what I named the Backups Level 1, daily images of the PCs data are created in disk drive #1 in an incremental manner using rsync. No data is ever erased from the backup disk. This Level 1 backups run around dinner time, which is convenient as typically all PCs at home are connected but no one is actually using them.

The Backups Level 2 also run daily but during the night when we are sleeping. The level 2 backup mirrors, also incrementally, the data in the disk drive #1 to disk drive #2. This way I have my data in three points: 
  1. My PCs
  2. Disk drive #1
  3. Disk drive #2

The Raspi board and PCs are connected to the same LAN, but while the PCs have dynamic IP addresses the Raspi is configured with a static IP address (see article about configuring a static IP address in the Raspi using Linux). This way the PCs always know how to communicate with my backups system.

Let's look at the scripts used both in each of the PCs and in the Raspi, all scripts are available for download in my GitHub repository homeBackupsSystem. Starting by the script running in the PCs, which you can see bellow, it's a simple rsync command. Remember that this script is being run by the CRON every day at evening (in my case). 

The script running in the Raspi is a simple rsync command. This script is being run by CRON every night. 

A note: One of my home PCs is running Windows instead of Linux, so I used the Task Scheduler to create a task that execute a batch file with the script.

And this was it... or so I though at the time... 

Comentários