[sqlite] Recover corrupt database

2016-01-28 Thread Dan Kennedy
On 01/27/2016 08:47 PM, J Decker wrote:
> I was wondering if the backup api (sqlite3_backup_init, et al. ) will
> help to recover a corrupt DB?  All the other mechanisms are an export
> and re-import into a new DB...
>
> The database exists in a encrypted database that it's really difficult
> to get the keys outside of the program and I don't look forward to
> doing something that iterates through sqlite_master to get all the
> tables do all the selects and re-insert... so I browsed the API and
> found the _backup_ stuff.. but; I'm starting to think that it will
> just be a faithful page replication and the result will still be
> corrupted.

Most likely, yes.

As you have surmised, the backup API does a page-by-page copy.

Dan.



[sqlite] Recover corrupt database

2016-01-27 Thread Simon Slavin

On 27 Jan 2016, at 2:28pm, Jay Kreibich  wrote:

> Generally speaking, there is no standard way to recover from a corrupt 
> database. The best policy is not to corrupt it in the first place.

True, but if you have to corrupt it in the first place,

1) Try using the shell tool to .dump and then .read a new version of the 
database, then check to see that the database is intact and how far back the 
most recent transaction is.

2) If the above fails, restore from the most recent uncorrupted backup you have.

Simon.


[sqlite] Recover corrupt database

2016-01-27 Thread Jay Kreibich

The backup API is not designed to recover corrupted databases.

Generally speaking, there is no standard way to recover from a corrupt 
database.  The best policy is not to corrupt it in the first place.  In 
practice, if you follow the rules, it is very very hard to corrupt a database.  
Just be sure you?re not breaking one of the rules; if the database is inside 
another database, I question how locks and matched auxiliary files (journal, 
for example) are being handled.

https://www.sqlite.org/howtocorrupt.html

  -j


On Jan 27, 2016, at 7:47 AM, J Decker  wrote:

> I was wondering if the backup api (sqlite3_backup_init, et al. ) will
> help to recover a corrupt DB?  All the other mechanisms are an export
> and re-import into a new DB...
> 
> The database exists in a encrypted database that it's really difficult
> to get the keys outside of the program and I don't look forward to
> doing something that iterates through sqlite_master to get all the
> tables do all the selects and re-insert... so I browsed the API and
> found the _backup_ stuff.. but; I'm starting to think that it will
> just be a faithful page replication and the result will still be
> corrupted.
> ( I don't know what the corruption is)
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

--  
Jay A. Kreibich < J A Y @ K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it, but showing 
it to the wrong people has the tendency to make them feel uncomfortable." -- 
Angela Johnson







[sqlite] Recover corrupt database

2016-01-27 Thread J Decker
On Wed, Jan 27, 2016 at 6:28 AM, Jay Kreibich  wrote:
>
> The backup API is not designed to recover corrupted databases.
>
> Generally speaking, there is no standard way to recover from a corrupt 
> database.  The best policy is not to corrupt it in the first place.  In 
> practice, if you follow the rules, it is very very hard to corrupt a 
> database.  Just be sure you?re not breaking one of the rules; if the database 
> is inside another database, I question how locks and matched auxiliary files 
> (journal, for example) are being handled.
>
It's not in another database, but rather a encrypted vfs.  I assume it
happened while debugging and stopping at a breakpoint and aborting the
process; in general use I don't expect this to happen.

*sigh* guess I get to implement the 'hard' way then.

> https://www.sqlite.org/howtocorrupt.html
>
>   -j
>
>
> On Jan 27, 2016, at 7:47 AM, J Decker  wrote:
>
>> I was wondering if the backup api (sqlite3_backup_init, et al. ) will
>> help to recover a corrupt DB?  All the other mechanisms are an export
>> and re-import into a new DB...
>>
>> The database exists in a encrypted database that it's really difficult
>> to get the keys outside of the program and I don't look forward to
>> doing something that iterates through sqlite_master to get all the
>> tables do all the selects and re-insert... so I browsed the API and
>> found the _backup_ stuff.. but; I'm starting to think that it will
>> just be a faithful page replication and the result will still be
>> corrupted.
>> ( I don't know what the corruption is)
>> ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
> --
> Jay A. Kreibich < J A Y @ K R E I B I.C H >
>
> "Intelligence is like underwear: it is important that you have it, but 
> showing it to the wrong people has the tendency to make them feel 
> uncomfortable." -- Angela Johnson
>
>
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Recover corrupt database

2016-01-27 Thread J Decker
I was wondering if the backup api (sqlite3_backup_init, et al. ) will
help to recover a corrupt DB?  All the other mechanisms are an export
and re-import into a new DB...

The database exists in a encrypted database that it's really difficult
to get the keys outside of the program and I don't look forward to
doing something that iterates through sqlite_master to get all the
tables do all the selects and re-insert... so I browsed the API and
found the _backup_ stuff.. but; I'm starting to think that it will
just be a faithful page replication and the result will still be
corrupted.
( I don't know what the corruption is)