<p>I have a set of Berkeley DB files on my Linux file system that I'd like to examine.</p>

<p>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.</p>

[{'answer_id': 37655, 'author': 'David Crow', 'author_id': 2783, 'author_profile': 'https://Stackoverflow.com/users/2783', 'pm_score': 6, 'selected': True, 'text': '<p>Check out the <strong>db-utils</strong> package. If you use apt, you can install it with the following: <code>apt-get install db-util</code>   (or <code>apt-get install db4.8-util</code> or whatever version you have or prefer.)</p>\n\n<p>Additional links:</p>\n\n<ul>\n<li><a href="http://rpmfind.net/linux/rpm2html/search.php?query=db-utils" rel="nofollow noreferrer">http://rpmfind.net/linux/rpm2html/search.php?query=db-utils</a></li>\n<li><a href="http://packages.ubuntu.com/search?keywords=db4.4-util" rel="nofollow noreferrer">https://packages.ubuntu.com/search?suite=default&amp;section=all&amp;arch=any&amp;keywords=db-util&amp;searchon=names</a></li>\n<li><a href="http://www.linux.gr/cgi-bin/man/man2html?db4.4_dump+1" rel="nofollow noreferrer">Man page of db4.4_dump</a></li>\n</ul>\n'}, {'answer_id': 9355977, 'author': 'Ishtiaq Ahmed', 'author_id': 1220151, 'author_profile': 'https://Stackoverflow.com/users/1220151', 'pm_score': 3, 'selected': False, 'text': '<p>The db_hotbackup utility creates "hot backup" or "hot failover" snapshots of Berkeley DB database environments. Install it with the following</p>\n\n<p><strong>apt-get install db-util</strong></p>\n\n<p>then run following command to take hot backup</p>\n\n<p><strong>db_hotbackup [-cDEguVv] [-d data_dir ...] [-h home] \n        [-l log_dir] [-P password] -b backup_dir</strong>  </p>\n'}, {'answer_id': 14886774, 'author': 'Gunnarsson', 'author_id': 751319, 'author_profile': 'https://Stackoverflow.com/users/751319', 'pm_score': 3, 'selected': False, 'text': '<p>Once you have installed the db utils you can simple do a <strong>db_dump</strong> on the db file.</p>\n'}, {'answer_id': 15533581, 'author': 'A.R. Pepper', 'author_id': 2192591, 'author_profile': 'https://Stackoverflow.com/users/2192591', 'pm_score': 2, 'selected': False, 'text': '<p>Note that the initial answer says to use "db-utils" package, but the example shows the correct "db-util" package.  (with no "s")</p>\n'}, {'answer_id': 19793412, 'author': 'strickli', 'author_id': 1612703, 'author_profile': 'https://Stackoverflow.com/users/1612703', 'pm_score': 3, 'selected': False, 'text': "<p>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.</p>\n\n<p>For a quick'n'dirty viewer, use python:</p>\n\n<pre><code>me@machine$ python\nPython 2.7.3 (default, Sep 26 2013, 20:03:06) \n&gt;&gt;&gt; import dbhash\n&gt;&gt;&gt; for k, v in dbhash.open( *&lt;db filename here...&gt;* ).iteritems(): print k, v\n...\n</code></pre>\n\n<p>Note that dbhash is deprecated since python 2.6.</p>\n"}, {'answer_id': 23018271, 'author': 'trjh', 'author_id': 2620, 'author_profile': 'https://Stackoverflow.com/users/2620', 'pm_score': 4, 'selected': False, 'text': '<p>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 <a href="https://pypi.org/project/bsddb3/" rel="nofollow noreferrer">bsddb</a></p>\n<pre><code># file foo.db\nfoo.db: Berkeley DB (Btree, version 9, native byte-order)\n\n# python\n&gt;&gt;&gt; import bsddb\n&gt;&gt;&gt; for k, v in bsddb.btopen(&quot;*&lt;db filename here...&gt;*&quot;).iteritems():\n...     print k,v\n...\n</code></pre>\n'}, {'answer_id': 29904764, 'author': 'Dan Herman', 'author_id': 1126719, 'author_profile': 'https://Stackoverflow.com/users/1126719', 'pm_score': 1, 'selected': False, 'text': '<p>Under Amazon Linux you can install it with:</p>\n\n<p><strong>yum install db43-utils</strong></p>\n'}, {'answer_id': 34377228, 'author': 'cdauth', 'author_id': 242365, 'author_profile': 'https://Stackoverflow.com/users/242365', 'pm_score': 6, 'selected': False, 'text': '<p>Use the <code>db_dump</code> program. It is contained in the package <code>core/db</code> (Arch), <code>db-util</code> (Debian, Ubuntu), <code>sys-libs/db</code> (Gentoo, note that here the binary is called <code>db4.8_dump</code> or whatever version you are using).</p>\n\n<p>On some systems the man pages are not installed, in that case the documentation can be found <a href="https://docs.oracle.com/cd/E17275_01/html/api_reference/C/db_dump.html" rel="noreferrer">here</a>. By default, <code>db_dump</code> outputs some hex numbers, which is not really useful if you are trying to analyse the content of a database. Use the <code>-p</code> argument to change this.</p>\n\n<p><strong>Show everything that’s in the file <code>database.db</code>:</strong></p>\n\n<pre><code>db_dump -p database.db\n</code></pre>\n\n<p><strong>List the databases in the file <code>database.db</code>:</strong></p>\n\n<pre><code>db_dump -l database.db\n</code></pre>\n\n<p><strong>Show only the content of the database <code>mydb</code> in the file <code>database.db</code>:</strong></p>\n\n<pre><code>db_dump -p -s mydb database.db\n</code></pre>\n'}, {'answer_id': 71243626, 'author': 'kenorb', 'author_id': 55075, 'author_profile': 'https://Stackoverflow.com/users/55075', 'pm_score': 1, 'selected': False, 'text': "<h3>Python 3</h3>\n<pre><code>from bsddb3 import db\nimport collections\nd = db.DB()\nd.open('./file.dat', 'dbname', db.DB_BTREE, db.DB_THREAD | db.DB_RDONLY)\nd.keys()\ncollections.OrderedDict((k, d[k]) for k in d.keys())\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/37644', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1951/']