Apr 072011
 

Originally quoted from www.digriz.org.uk (but the page no longer exists)…because the rsync support for backupninja (or at least the Debian one) is a bit naff…or I just simply do not understand it. Very true if a little surprising since all the other backupninja handlers have always worked very well for me. Backupninja is wonderful for creating a backup system, run these shell commands, hotcopy those databases, rdiff-backup the result and rsync or duplicity all that somewhere else. Wonderful stuff now lets fix rsync.

P.S: if you do know how to make the supplied rsync handler work then please post a comment.

The backupninja supplied rsync handler might be able to do rotations when all I want is a mirror…but as far as actual backup even the simplest config causes trouble.

/etc/backup.d/10.TunesToBak.rsync:

[general]
mountpoint = /mnt/1
days = 30
 
[source]
from = local
include = /tunes

Note: example taken from an official backupninja bug, I have also tried and failed with many other combinations.

All I get is this:

Info: >>>> starting action /etc/backup.d/10.rsync (because of --now)
Debug: yes
Info: Rotating /mnt/1///tunes...
Info: Syncing /tunes on /mnt/1///tunes/tunes.0/...
Debug: nice -n 0 /usr/bin/rsync -av --delete --recursive --numeric-ids //tunes/ /mnt/1///tunes/tunes.0/
rsync: -av --delete --recursive --numeric-ids: unknown option
rsync error: syntax or usage error (code 1) at main.c(1443) [client=3.0.7]
Info: <<<< finished action /etc/backup.d/10.rsync: SUCCESS
Debug: send report to root
Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning.

So even though the backup clearly failed there are no errors reported! What the hell is up with all the extra ////’s! The strange thing is that manually running the rsync command that debug outputs works just fine. Smells bad, in every example that I found people are using the .sh handler to rsync just as I was, at least this is simple and works but often suffers from not reporting rsync errors. Seems there is a need for a .rsyncsimple handler.

Handler .sh

Turns out that the .sh handler is smarter than explicitly mentioned in the docs, it can report errors!

# This script can run most any command normally run on the command line.
# Add anything usefull that you would like to do during a backup.
# Handler output functions may be used:
#    * debug $msg -- log debugging info
#    * info $msg -- log general information.
#    * warning $msg -- log a warning
#    * error $msg -- log an error
#    * fatal $msg -- log a fatal error and exit
 
# (1) a list of all the packages installed and removed.
#     this file can be used to restore the state of installed packages
#     by running "dpkg --set-selections < dpkg-selections.txt"
 
BAK_GET_SELECTIONS="ssh root@host 'dpkg --get-selections > /var/backups/dpkg-selections.txt'"
eval $BAK_GET_SELECTIONS || fatal "$BAK_GET_SELECTIONS"
 
# (2) used with along with /etc/fstab and /var/backups/partitions.hdx.txt
#     to decide on how to partition a new disk during a recovery.
#     possibly by running "sfdisk /dev/sdx < partitions.hdx.txt"
#      (MAKE SURE YOU PARTITION THE CORRECT DISK!!!)
 
BAK_DF="ssh root@host 'df > /var/backups/df.txt'"
eval $BAK_DF || fatal "$BAK_DF"

Handler .rsyncsimple

Turns out Chris Lamb felt the same way and posted a Debian bug report with a GLP’d .rsync_ssh handler. Thanks Chris!

Sadly I’ve just upgraded to Debian 6.0 “Squeeze” and even with the new ‘mirror’ option I don’t get what I want. So adapting .rsync_ssh I think we can get .rsyncsimple, retain Chris’s ssh functionality and put it on gist.github.com! More tomorrow 01:30 and bed time…

Gavin Kromhout:


Thank you for visiting.
Do look around.
Do leave a comment.

  2 Responses to “Backupninja rsync handler”

  1. I’ve noticed the same problem with the .rsync handler. I seems unusual that others aren’t hitting this problem, and the issue solved.

  2. I actually have started writing a handler, trying to do it ‘the right way’ I started the tests script first and ran out of time…so my backups haven’t been done lately. Soon I will have to use the .sh handler (but at least with improved error reporting). I have the scripts if anyone would like to add to what I have done so far.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)