Saturday, August 20, 2016

Setting Up a Personal Backup System



Backups are critical. If I could only save one (inanimate) entity from a fire or similar, that would be my laptop or more specifically, the data on it. While some bits and pieces of my work are usually backup up in remote code repositories, its hard to believe that until recently I did not have a comprehensive personal backup system in place. While I've heard good things about Apple Time Capsule, here I describe how I set up a backup system using a couple of regular Seagate external drives that I already owned. 



My goal for this system: To set up a 'backup' command to run from the terminal that performs a back of all my important data.



Step 1: Make a list of all important files and folders to back up.  This also helped to organize my data and get rid of all the clutter. Some of these for me were:


  • All the settings settings files for the IDEs I'm using. These settings files are usually stored in different places but I think its important to have those settings fine tuned over the years backed up.
  • Work files. I ended up organizing all my work related files inside a single work folder. 
  • My Documents folder.
  • Pictures and other media.


Step 2: Write a shell script. This is the main backup script. As an example, here is a link to my backup shell script. It allows me to pick from a list of my personal external drives. Also it allows to select form performing either incremental or full backups. In the script, I use the "rsync" command (as opposed to "cp") as it affords the incremental backup option. The list of files and folders to backup are stored in another file "include.txt". Finally, it records the time and other metadata regarding the backup in another text file "latest.txt".


Step 3: Add an alias to you "~/.bash_profile". This makes performing a backup as simple as typing a single command in the terminal. We only need to add the following line to "~/.bash_profile".



alias backup="path_to_backup_script"/backup.sh"



Step 4: Add a recurring backup reminder to the calendar application. This is a simple but important step. I prefer not fully automating the backup to prevent it from annoyingly starting up when I am working on a compute intensive task. Just adding a calendar reminder makes sure that I don't go without running the backup script too long.




No comments:

Post a Comment