Quick-n-dirty Darktable library backup script

One feature that Lightroom has which I think Darktable needs is the ability to perform a backup of your current catalog from within the application. Lightroom checks every week to see if you’ve made a backup recently, and then prompts you to make one. You can ignore it, of course, but you never know when you’re going to want that backup.

While I figure out a way to make this happen from within Darktable, I’ve got this little quick-n-dirty shell script which I run out of cron at midnight every night:

#!/bin/bash
DTLIB=$HOME/.config/darktable/library.db
DTNEWLIB=${DTLIB}-`/usr/bin/date +%Y%m%d_%H%M`
ECHO=/bin/echo
SQLITE3=/usr/bin/sqlite3

RESULT=`$ECHO .dump | $SQLITE3 $DTLIB | $SQLITE3 $DTNEWLIB`

if [ $? -eq 0 ]; then
    $ECHO "Dumped $DTLIB to $DTNEWLIB"
else
    $ECHO "FAILED to dump $DTLIB to $DTNEWLIB"
    exit RESULT
fi