[lug] How to recover berkeley databases?

Andrew Diederich andrewdied at gmail.com
Fri Nov 11 10:42:04 MST 2005


I'm in the process of moving away from berkeley db.  A lot of it is
because of reasons like this; the tools in berekley are freakishly
hard to use.  My db is version 3.2.9.
db_dump -V
Sleepycat Software: Berkeley DB 3.2.9: (January 24, 2001)


My database (jabber:iq:roster) is corrupt.

$ db_verify jabber\:iq\:roster
db_verify: Bad pgno: was 856319599, should be 0
db_verify: Bad magic number: 1952542066
db_verify: Bad page size: 1702257004
db_verify: Unknown page type: 101
db_verify: Bad page number: 808674611 should be 1
db_verify: Bad page type: 51
db_verify: Unknown page type: 51
...
db_verify: Bad page number: 1664497974 should be 112
db_verify: Queue databases must be one-per-file.
db_verify: Queue record length 859255862 impossibly high for page size
and records per page
db_verify: DB->verify: jabber:iq:roster: DB_VERIFY_BAD: Database
verification failed

I've tried a straight "db_recover", but it doesn't change anything.
$ db_recover -v
db_recover: Recovery complete at Fri Nov 11 10:21:40 2005
db_recover: Maximum transaction id 80000000 Recovery checkpoint [0][0]


Indications are I should run a db_dump and then a db_restore.  I've
tried both the -r (dump the records) and -R (really, really dump the
records) all I get is
$ db_dump -R jabber\:iq\:roster
VERSION=3
format=bytevalue
type=btree
HEADER=END
DATA=END

which makes me sad.  Heck, the -l (list dbs) option doesn't even
realize my target file is a bdb file.
$ db_dump -l jabber\:iq\:roster
db_dump: jabber:iq:roster: unexpected file type or format
db_dump: open: jabber:iq:roster: Invalid argument

Now, if I use python, I can get individual records out.
>>> import bsddb
>>> roster = bsddb.btopen('jabber:iq:roster', 'r')
>>> roster['keyname']

gives me that key.

So, I'm trying to figure a way with the native berkeley tools to get
my data so I can put it in a regular RDB.  Any help is appreciated.

--
Andrew Diederich



More information about the LUG mailing list