Automatic Database Backup

Script contributed by Andrzej

Here is a backup script for Opennebula SQlite database in case someone finds it useful. I run it from cron like that

01 5 * * * /root/bin/ 2>&1 |logger

And here goes the script itself, it's based on mysql dump script I found somewhere on the web:

# This is a simple script to create a snapshot of a Opennebula SQLite DB
# Send bugreports, fixes, enhancements, t-shirts, money, beer & pizza
# to
# Directory to store backups in
# Any backups older than this will be deleted first
DATE=$(date  +%Y-%m-%d)
#------------ code
/usr/bin/logger "Starting ONEDB Dump....."
find ${DST} -type f -mtime +${KEEPDAYS} -exec rm -f {} \;
mkdir -p ${DST}
onedb backup --sqlite /var/lib/one/one.db ${DST}/onedb-${DATE}.backup
tar -czf ${DST}/onedb-${DATE}.tar.gz ${DST}/onedb-${DATE}.backup
rm ${DST}/onedb-${DATE}.backup
/usr/bin/logger "OK, all ONEDB dumps done in $DST"
automatic_database_backup · Last modified: 2013/08/14 19:37 by Jaime Melis
Admin · Login