Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Examining Berkeley DB files from the CLI

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.

like image 222
mercutio Avatar asked Sep 01 '08 09:09

mercutio


People also ask

How do I open a Berkeley DB file in Linux?

Use the db_dump program. It is contained in the package core/db (Arch), db-util (Debian, Ubuntu), sys-libs/db (Gentoo, note that here the binary is called db4. 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.

What is the use of db_dump?

The db_dump utility reads the database file file and writes it to the standard output using a portable flat-text format understood by the db_load utility. The file argument must be a file produced using the Berkeley DB library functions.


2 Answers

Use the db_dump program. It is contained in the package core/db (Arch), db-util (Debian, Ubuntu), sys-libs/db (Gentoo, note that here the binary is called db4.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:

db_dump -p database.db 

List the databases in the file database.db:

db_dump -l database.db 

Show only the content of the database mydb in the file database.db:

db_dump -p -s mydb database.db 
like image 189
cdauth Avatar answered Sep 22 '22 02:09

cdauth


Check out the db-utils package. If you use apt, you can install it with the following: apt-get install db-util (or apt-get install db4.8-util or whatever version you have or prefer.)

Additional links:

  • http://rpmfind.net/linux/rpm2html/search.php?query=db-utils
  • https://packages.ubuntu.com/search?suite=default&section=all&arch=any&keywords=db-util&searchon=names
  • Man page of db4.4_dump
like image 45
David Crow Avatar answered Sep 22 '22 02:09

David Crow