BlogAutomatic Server Backups using SpiderOak

Automatic Server Backups using SpiderOak

Posted by Jesse on July 29, 2013

I must admit, I'm a bit of paranoid when it comes to data loss.  When I was a kid, my hard drive crashed and I lost everything I ever had up until that point.  I've been a Mozy subscriber for years on all of our desktops and laptops.  On the server side of things, however, I've been completely lacking -- until now.

For years, I've been crossing my fingers for an easy Mozy solution, but that still hasn't panned out.  I gave Dropbox and its clones a try, which tend to work, but I hate having all my backup data synced across all computers.  I'm also not a fan of Dropbox's lack of encryption.

I decided I'd give SpiderOak a try with the sole purpose of backing up my Debian servers, and wow, I'm impressed and I'm going to stick with it.  

Here's how I did it:

First, I ignored the install instructions on the SpiderOak website for debian.  I found their deb package didn't do everything it was supposed to do (like add the repo to the sources.list file).

Instead, I added the line below myself to /etc/apt/sources

deb http://apt.spideroak.com/debian/ stable non-free

I also had to trust the repository

gpg --keyserver pgpkeys.mit.edu --recv-key 5D654504F1A41D5E
gpg -a --export 5D654504F1A41D5E | sudo apt-key add -
Next, install spideroak as you would any debian package
apt-get update
apt-get install spideroak
And run the setup wizard as root (since backups will be run as root)
SpiderOak --setup=-
rm -rf SpiderOak\ Hive
Notice  that I removed the SpiderOak Hive directory.  Hive is SpiderOak's implementation of multi-computer syncing, but I don't really care about that.
 
After that, I put the following script (modified with the proper directories of course) into /etc/cron.daily. 
 
#!/bin/bash

log_file="/var/log/backup"
 
backups=(
  /etc
  # directories
  #     to
  #   backup
)
 
cmd="SpiderOak --backup="
 
date=`date`
echo "Starting at $date" >> $log_file
 
for backup_loc in "${backups[@]}"
do
  echo "Backing up: $backup_loc" >> $log_file
  if [ -d "$backup_loc" ]; then
    echo "Backing up directory $backup_loc ... " >> $log_file
    $cmd$backup_loc >> $log_file
  elif [ -f "$backup_loc" ]; then
    echo "Backing up file $backup_loc ... " >> $log_file
    $cmd$backup_loc >> $log_file
  else
    echo "Error! $backup_loc could not be found." >> $log_file
  fi
done
 
echo "Done
 
" >> $log_file

That's it!  Now I've got daily automated backups of my servers.

Comments:

Leave a Reply



(Your email will not be publicly displayed.)


Captcha Code

Click the image to see another captcha.