push or pull

I've looked at sbackup and I'm a bit disappointed :(

It's true that it has a nice GUI and has many interesting features. But I can't get it to work nicely. First of all, I could not add my root directory (/) as a directory to be backed up. I had to edit the configuration file manually to get it in there. Then, for some reason, it started backing up my files locally instead of remote by making a giant tarball in /var/backup. That's not good :/
It's not like I forgot to set it to "remote backup". I even entered the correct information and setup an SSH-key. But sbackup "forgot" my settings and decided to stay local anyway.

There's also a bugreport that claims sbackup is slow on a large collection of files (O(n^2)). The buglist makes it appear as if sbackup has been abandoned. And this feeling is only strengthened by the spam on the SBackup wiki

In light of all this, I decided to look away from sbackup and consider alternatives. Most of the backup solutions (if not all...) are concerned with backing up specific directories and archiving them.
In my case, I want a FULL system backup and I don't need an archive. A mirror is enough.

So I'm going to drop the search and go with rsync. One of the problems I encountered during testing, is that I have to login as root on the remote host to preserve ownerships of files. There will have to be a large shift in my life before I allow something like root-ssh-keys stored on my laptop, just to do backups....

Instead of pushing the backups, I will do a pull from my desktop computer. I can store a public SSH-key of my desktop machine on my laptop to allow automatic backups. If I don't want backups at some point, I can just remove the key.
Another advantage of using pull instead of push, is that I can backup at work AND at home, without modifying my laptop setup. Added bonus: if there's no network on my laptop, backups won't be started anyway because they are initiated from the remote site.

I'll be working on a script to send me a notification when backup starts and when it ends. This script should be called by the remote host so that I'm notified that my laptop might be sluggish.

This is what I whipped up.

On the remote site I have this script:


startstopscript="su guest -c \"/home/guest/bin/backup_startstop"

# notify the client that backup is about to start
starttime=`date +%s`
ssh root@$remotesite "$startstopscript start $host\""

# do an rsync of the entire disk
rsync -e "ssh -l root" -ax $remotesite:/ $localstore &> /dev/null

# notify the client that backup has ended and report runtime
stoptime=`date +%s`
delta=$(($stoptime - $starttime))
ssh root@$remotesite "$startstopscript stop $host $delta\""

On the client computer (the laptop), I have this script:



# the send_notification function sends a notification message to the dbus-daemon
# which pops up a message on the screen of the user.
# This script is sortof dirty because we locate an environment variable in /proc/
# somewhere, and the icon used is hardcoded.
local title=$1
local text=$2

for i in `pgrep -fu guest x-session-manager`;
x=`cat /proc/$i/environ 2> /dev/null| grep -z DBUS_SESSION_BUS_ADDRESS`
if [ -n "$x" ];
export "$x"

notify-send -i /home/guest/images/backup.gif "$title" "$text"

function sec_to_read {

d=$(($s / 86400)); s=$(($s % 86400)); if [ $d -gt 0 ]; then out="$out$d day(s) "; fi
d=$(($s / 3600)); s=$(($s % 3600)); if [ $d -gt 0 ]; then out="$out$d hour(s) "; fi
d=$(($s / 60)); s=$(($s % 60)); if [ $d -gt 0 ]; then out="$out$d minute(s) "; fi
if [ $s -gt 0 ]; then out="$out$s second(s)"; fi

echo $out;

case "$cmd" in
send_notification "Autobackup started" "Automatic backup has started from $host"
delta=$(sec_to_read $delta)
send_notification "Autobackup ended" "Automatic backup from $host has ended. Total runtime: $delta"

exit 0

And this is backup.gif:

(Shamelessly ripped from some site)