Manoj M wrote:

> Hi,
> 
> I am working with a project that requires a SQLite recovery module.
> 
> I have a corrupted database(see the link below) where if I am issuing
> a query like "select * from objects where dbname='information_schema'"
> leads to application crash(even sqlite commandline program). As I was
> looking for possible ways, I saw sqlite command-line program is able
> to dump my sample corrupted database and then able to create a new
> database from this(using .read filename).
> 
> Is this(.dump) is the standard for recovering a corrupted database?
> what is special with .dump commad? can we also follow the same method
> for crash recovery? Is there any other better method to do it(using
> some exception handling)?
> 
> sample corrupted db attached
> https://rcpt.yousendit.com/624254893/4d5c40a04a2eb6cdf2468bd999485ef2
> 
> Thanks in advance!
> 
> Regards,
> Manoj Marathayil

hi,

the .dump command isn't reliable if the database is corrupt.

i also needed the ability to restore an sqlite3 database
after a corruption. my approach was to have the application
record all database inserts and updates into a history table
within the database and to text/log file as well.

my backup script would test for database corruption (with
"sqlite3 dbpath 'pragma integrity_check'") before doing the
backup (with "sqlite3 dbpath .dump"). if the database is
corrupt, it would restore the previous good backup, then it
would run a recovery program which identifies the difference
between the history table and the history log file and
reapply any inserts or updates that are present in the log
file but not in the history table.

of course, you need all of this set up in advance,
before your first corruption.

cheers,
raf

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to