Database corruption

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Database corruption

Mrs. Brisby
I had some MacOSX systems suffer a power failure, when they came back I made some copies of the database and:<br>
<br>
sqlite&gt; PRAGMA integrity_check;<br>
*** in database main ***<br>
On tree page 39134 cell 65: 2nd reference to page 33247<br>
On tree page 39134 cell 65: Child page depth differs<br>
On tree page 39134 cell 66: Child page depth differs<br>
Page 33220 is never used<br>
wrong # of entries in index t1<br>
SQL error: database disk image is malformed<br>
<br>
I need to repair these databases in a hurry, but I'm not 100% sure where to start.<br>
<br>
No, they're not all the same.<br>
<br>
Any suggestions?<br>

Reply | Threaded
Open this post in threaded view
|

Re: Database corruption

D. Richard Hipp
"Mrs. Brisby" <[hidden email]> wrote:
> I had some MacOSX systems suffer a power failure, when they came back
> I made some copies of the database and: [integrity_check failed]

This suggests that you copied only the database file itself and
not its rollback journal.  That can lead to corruption.

The best fix is to go get a fresh copy of both the file and its
rollback journal, make sure they both are in the same directory, then
open the database file.  The journal will be read and will automatically
roll back pending changes, restoring the database to a consistent state.

Failing that, you can try to do a ".dump" of the database into
a fresh database.  If ".dump" gives problems, try running it separately
for each table in the database file.  You should be able to recover
most of your data that way, but some patching and fixing will still
likely be necessary once you are done.
--
D. Richard Hipp <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: Database corruption

Mrs. Brisby
On 2005-10-07 at 11:11, <a href="http://tick/%7Egeocar/netmail/ws.cgi?action=v2;.to=drh@...">[hidden email]</a> wrote:
&nbsp;<br>
&gt; "Mrs. Brisby" &lt;<a href="http://tick/%7Egeocar/netmail/ws.cgi?action=v2;.to=mrs.brisby@...">[hidden email]</a>&gt; wrote:
&nbsp;<br>
&gt;
&nbsp;<br>
&gt; &gt; I had some MacOSX systems suffer a power failure, when they came back
&nbsp;<br>
&gt; &gt;  I made some copies of the database and: [integrity_check failed]
&nbsp;<br>
&gt;
&nbsp;<br>
&gt;
&nbsp;<br>
&gt; This suggests that you copied only the database file itself and not its
&nbsp;<br>
&gt; rollback journal.  That can lead to corruption.
&nbsp;<br>
<br>
There was no rollback journal.&nbsp; This is why I'm worried.<br>
<br>
&gt; Failing that, you can try to do a ".dump" of the database into a fresh
&nbsp;<br>
&gt; database.  If ".dump" gives problems, try running it separately for
&nbsp;<br>
&gt; each table in the database file.  You should be able to recover most of
&nbsp;<br>
&gt; your data that way, but some patching and fixing will still likely be
&nbsp;<br>
&gt; necessary once you are done.<br>
<br>
.dump appears to work for most data. I'm using this.<br>