Amarok backup script

patvdv — Fri, 05/06/2009 - 15:54
I am a big fan of the superb music player and organizer AmaroK, one of KDE's flagship programs. AmaroK supports multiple database backends for storing information about the music collection (e.g. mp3 files) and until recently I was using the default SQLite backend. The amarok SQLite database is located in the user's home directory and as such it is pretty important to have a decent backup of the AmaroK database in case a calamity occurs. What follows is the listing for a very simple AmaroK backup script that uses the SQLite backend.
Note: you should adjust the variables DUMP_DIR, DUMP_FILE and LOG_FILE variables at the beginning of the script.
#!/bin/bash
#
# This script make as copy of the amaroK SQLite DB
#
DUMP_DIR="/home/patrick/shares/backup/amarok"
DUMP_FILE="$DUMP_DIR/backup_amarokdb_$(date '+%H%M-%d%m%Y').tar"
LOG_FILE="$HOME/logs/backup_amarok_sqlitedb.log"
if [[ ! -d $DUMP_DIR ]]
then
mkdir -p $DUMP_DIR
fi
mkdir $DUMP_DIR >/dev/null 2>&1
START_TIME=$(date '+%s')
echo "INFO: starting backup of amaroK SQLite DB at $(date '+%X')" | tee -a $LOG_FILE
cd $HOME
tar cvf $DUMP_FILE .kde/share/apps/amarok/*
tar rvf $DUMP_FILE .kde/share/config/amarok*
gzip $DUMP_FILE
echo "INFO: finished backup of amaroK SQLite DB at $(date '+%X')" | tee -a $LOG_FILE
FINISH_TIME=$(date '+%s')
DURATION=$(($FINISH_TIME - $START_TIME))
SIZE=$(ls -s ${DUMP_FILE}.gz | cut -f1 -d" ")
echo "INFO: backup complete (duration: $DURATION seconds / size: $SIZE KB)" | tee -a $LOG_FILE
exit 0
Bookmark/Search this post with:
Delicious
Digg
StumbleUpon
Propeller
Reddit
Magnoliacom
Google
Yahoo
Technorati
Recent comments
1 week 16 hours ago
2 weeks 6 days ago
2 weeks 6 days ago
2 weeks 6 days ago
2 weeks 6 days ago
9 weeks 5 days ago
9 weeks 5 days ago
41 weeks 5 hours ago
41 weeks 9 hours ago
41 weeks 4 days ago