[PyAR2] cron job to backup sqlite database?

Larry Hale pythonlarry at gmail.com
Fri Sep 7 22:43:45 CEST 2012


That'll work!  :>

-L


On Fri, Sep 7, 2012 at 1:00 PM, Chad Cooper <supercooper at gmail.com> wrote:

> Interesting. Right now I have this cron job implemented to dump the
> database to a backup file:
>
> 5 6 * * * sqlite3 /home/pyarkansas/webapps/symposion/symposion/dev.db
> .dump > /home/pyarkansas/backups/`date +\%m`-`date +\%d`-`date +\%Y`_`date
> +\%H`-`date +\%M`-`date +\%S`.bak
>
>
>
> On Fri, Sep 7, 2012 at 12:50 PM, Larry Hale <pythonlarry at gmail.com> wrote:
>
>> Sorry so late to all these parties.  "Life."  UGH.  Trying to play
>> catch-up as I get some minutes... mostly getting caught up reading (tagging
>> some to look at in more detail).  I've reached "here" as of "now"...  ;o)
>>
>> So, in addition to Wayne's link of official SQLite Backup API docs, for
>> "how to access via Py" (if that's of interest), might look at THIS<http://blog.marcus-brinkmann.de/2010/08/27/how-to-use-sqlites-backup-in-python/>.
>> *I* have not tried, and I'm not sure how much of an effort it'd be to
>> install/setup APSW <http://code.google.com/p/apsw/> (yet another lib).
>> But some items to look at.
>>
>>
>>
>> On Thu, Aug 16, 2012 at 7:55 PM, Wayne Werner <wayne at waynewerner.com>wrote:
>>
>>> On Thu, 16 Aug 2012, Chad Cooper wrote:
>>>
>>>  All,
>>>> I need to create a cron job on the webserver to backup the sqlite db
>>>> behind
>>>> http://www.pyarkansas.org. I'm a noob to sqlite, so should I actually
>>>> dump
>>>> the db to a backup or just copy is somehow? I'm thinking with copying it
>>>> can't be being accessed during the copy or it could be corrupted.
>>>>
>>>> Anyone done this before, gotta be simple, huh?
>>>>
>>>
>>> A SQLite db is just a file, so a plain cp should be just fine. There
>>> *might* be an issue with a write happening during read, but my guess is
>>> that any issues should be extremely rare. If we want to be paranoid about
>>> it we could always do two backups a minute apart - then checksum the db's
>>> against eachother and the main db. If they all match, great. If the backups
>>> don't match each other, but one of them matches the master, then I *think*
>>> we could just assume that the stars aligned and we read at the exact same
>>> time a write happened.
>>>
>>> Although a quick DuckDuckGo search yielded this:
>>> http://www.sqlite.org/backup.**html <http://www.sqlite.org/backup.html>
>>>
>>> And possibly this: http://linux.softpedia.com/**
>>> get/Database/Database-APIs/**python-sqlite3-backup-83306.**shtml<http://linux.softpedia.com/get/Database/Database-APIs/python-sqlite3-backup-83306.shtml>
>>>
>>> (Also, apparently I didn't send this off this morning like I thought!)
>>> -Wayne
>>> _______________________________________________
>>> PyAR2 mailing list
>>> PyAR2 at python.org
>>> http://mail.python.org/mailman/listinfo/pyar2
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pyar2/attachments/20120907/43ca22b9/attachment-0001.html>


More information about the PyAR2 mailing list