Question

I have a Berkeley DB file which has some data in a record which is corrupt.

The record contains xml and the xml tag is not correct.

In one of the records contains:

"<modifications></modificatio"

How can i edit this record to fix this in

"<modifications></modifications>"
Was it helpful?

Solution

A Berkeley database file is a binary file containing database records that have been placed there by an application.

You would typically "edit" the file using whatever tool you used to generate it in the first place. If that's not available to you, the easiest solution is probably to use the db_dump and db_load commands.

The db_dump command transforms a database into a text format, like this:

$ db_dump my_broken_database
format=print
type=hash
h_nelem=77
db_pagesize=4096
HEADER=END
 key1\00
 this is a value\00
 key2\00
 this is another value\00
DATA=END

You can dump this to a file...

$ db_dump my_broken_database > data.txt

... and edit this with your favorite text editor. Once you've made your edits, you feed it to db_load to regenerate the database:

$ db_load my_fixed_database < data.txt
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top