[one-users] backup script for SQLite DB
Andrzej
andrzej at mielnet.pl
Tue Jan 8 07:31:29 PST 2013
Hi guys,
Just so my presence on this list is not only marked by begging for help
but also some contributing :-)
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/onedb.sh 2>&1 |logger
And here goes the script itself, it's based on mysql dump script I found
somewhere on the web:
#!/bin/bash
#--------------------------------------------------------------
# This is a simple script to create a snapshot of a Opennebula SQLite DB
# Send bugreports, fixes, enhancements, t-shirts, money, beer & pizza
# to andrzej at mielnet.pl
#--------------------------------------------------------------
# Directory to store backups in
DST=/backup/opennebula
# Any backups older than this will be deleted first
KEEPDAYS=10
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"
#--------------------------------------------------------------
Not that I needed a backup but someday, who knows.
Any comments or improvements are welcomed :-)
All the best,
Andrzej
More information about the Users
mailing list