I have a set of Berkeley DB files on my Linux file system that I'd like to examine.
What useful tools exist for getting a quick overview of the contents? I can write Perl scripts that use BDB modules for examining them, but I'm looking for some CLI utility to be able to take a look inside without having to start writing scripts.
I found @strickli's answer to be the most helpful, as I didn't want to add any new packages to the machine with the database I was on. However, the db file I was reading was of type btree, not hash, so I had to use bsddb
Under Amazon Linux you can install it with:
yum install db43-utils
Check out the db-utils package. If you use apt, you can install it with the following:
apt-get install db4.4-util
(orapt-get install db4.8-util
or whatever version you have or prefer.)Additional links:
As mentioned in the other answers, the db-utils package (db4-utils under RHEL) has some tools. However, db_dump can be unhelpful, since the output is 'bytevalue' format.
For a quick'n'dirty viewer, use python:
Note that dbhash is deprecated since python 2.6.
Once you have installed the db utils you can simple do a db_dump on the db file.
Use the
db_dump
program. It is contained in the packagecore/db
(Arch),db-util
(Debian, Ubuntu),sys-libs/db
(Gentoo, note that here the binary is calleddb4.8_dump
or whatever version you are using).On some systems the man pages are not installed, in that case the documentation can be found here. By default,
db_dump
outputs some hex numbers, which is not really useful if you are trying to analyse the content of a database. Use the-p
argument to change this.Show everything that’s in the file
database.db
:List the databases in the file
database.db
:Show only the content of the database
mydb
in the filedatabase.db
: