Simple Dropbox BackUp on Raspberry Pi

So one of my Raspberry Pis died. I think the USB hub was faulty causing power spikes that eventually fried the SD cards and Pi circuitry.

Luckily my workflow of working on the iPad meant the code was all still intact on Textastic. It did, however, make me implement a basic backup system. This goes something like this.

  1. Create a directory to backup – I chose a directory called MyCode in the Home directory.
  2. Stick all files and folders I want backed up in this backup directory (and work out of it).
  3. Log all installed programs – add the log to the backup directory.
  4. Compress all files in directory.
  5. Write a script to upload compressed file to Dropbox.
  6. Schedule the script to run daily at midnight.

In more detail, 3) involves running the script:

dpkg --get-selections > /home/[username]/MyCode/installedsoftware.log

4) involves:

tar -zcvf [archive-name].tar.gz [directory-path]

5) then involves following the directions found here: . The command to upload a directory is something like this:

bash /home/[username]/MyCode/Dropbox-Uploader/ upload /home/[username]/[backupname].tar.gz /backup

6) involves adding a CRON entry:

crontab -e

looking like this:

0 0 * * * bash [path to backup script]/

It’s not pretty but it is better than nothing. If anyone else has a more elegant solution let me know.