Am 19.04.2010 um 20:11 schrieb P Kishor:

>> 3) From a linux box whats the easiest way of backing up the db  in perl or 
>> shell?
>> 
>> Can I lock the $sqlitedb first (how?) and then cp $sqlitedb 
>> /usr/local/db/backup
>> 
> 
> There is no concept of locking a db in sqlite. A sqlite db is just a
> file, just like any other file in your computer... a file that you can
> see, touch, move, rename. Just rename the db to db.backup, and create
> a new db. If you want to do all these shenanigans while you have other
> users connected to your db then --
> 
> you should either use sqlite's new backup facility (which I have never
> bothered learning, yet)
> 
> or, use a real client/server db such as Pg which will allow you to
> shut down/lock the db.


Well, besides using the new backup APIs, you could also start an immediate 
transaction with "BEGIN IMMEDIATE", which has the effect of locking the 
database for write access (since SQLite uses file-based locking). It should 
then be safe to copy the database file. When done, rollback the transaction.

Please correct me if this is not safe...

</jum>

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to