[one-users] backup script for SQLite DB

Javier Fontan jfontan at opennebula.org
Wed Jan 9 06:59:55 PST 2013


I've just copied your mail to the community wiki so other users could
find it more easily.

http://wiki.opennebula.org/automatic_database_backup

Thanks!

On Tue, Jan 8, 2013 at 4:31 PM, Andrzej <andrzej at mielnet.pl> wrote:
> 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
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org



-- 
Javier Fontán Muiños
Project Engineer
OpenNebula - The Open Source Toolkit for Data Center Virtualization
www.OpenNebula.org | jfontan at opennebula.org | @OpenNebula



More information about the Users mailing list