The Command Line Tools

DbDump
DbLoad
DbVerify

JE ships with several command line tools that you can use to help you manage your databases. They are:

DbDump

Dumps a database to a flat-text representation. Options are:

-f

Identifies the file to which the output from this command is written. The console (standard out) is used by default.

-h

Identifies the environment's directory. This parameter is required.

-l

Lists the databases contained in the environment. If the -s is not provided, then this argument is required.

-p

Prints database records in human-readable format.

-r

Salvage data from a possibly corrupt file. When used on a uncorrupted database, this option should return data equivalent to a normal dump, but most likely in a different order.

This option causes the ensuing output to go to a file named dbname.dump where dbname is the name of the database you are dumping. The file is placed in the current working directory.

-R

Aggressively salvage data from a possibly corrupt file. This option differs from the -r option in that it will return all possible data from the file at the risk of also returning already deleted or otherwise nonsensical items. Data dumped in this fashion will almost certainly have to be edited by hand or other means before the data is ready for reload into another database.

This option causes the ensuing output to go to a file named dbname.dump where dbname is the name of the database you are dumping. The file is placed in the current working directory.

-s

Identifies the database to be dumped. If this option is not specified, then the -l is required.

-v

Prints progress information to the console for -r or -R mode.

-V

Prints the database version number and then quits. All other command line options are ignored.

For example:

> java com.sleepycat.je.util.DbDump -h . -p -s VendorDB  
VERSION=3
format=print
type=btree
database=VendorDB
dupsort=false
HEADER=END
 Mom's Kitchen
 sr\01\01xpt\00\0d53 Yerman Ct.t\00\0c763 554 9200t\00\0bMiddle Townt\00
 \0eMaggie Kultgent\00\10763 554 9200 x12t\00\02MNt\00\0dMom's Kitchent\00
 \0555432
 Off the Vine
 sr\01\01xpt\00\10133 American Ct.t\00\0c563 121 3800t\00\0aCentennialt\00
 \08Bob Kingt\00\10563 121 3800 x54t\00\02IAt\00\0cOff the Vinet\00\0552002
 Simply Fresh
 sr\01\01xpt\00\1115612 Bogart Lanet\00\0c420 333 3912t\00\08Harrigant\00
 \0fCheryl Swedbergt\00\0c420 333 3952t\00\02WIt\00\0cSimply Fresht\00\0
 553704
 The Baking Pan
 sr\01\01xpt\00\0e1415 53rd Ave.t\00\0c320 442 2277t\00\07Dutchint\00\09
 Mike Roant\00\0c320 442 6879t\00\02MNt\00\0eThe Baking Pant\00\0556304
 The Pantry
 sr\01\01xpt\00\111206 N. Creek Wayt\00\0c763 555 3391t\00\0bMiddle Town
 t\00\0fSully Beckstromt\00\0c763 555 3391t\00\02MNt\00\0aThe Pantryt\00
 \0555432
 TriCounty Produce
 sr\01\01xpt\00\12309 S. Main Streett\00\0c763 555 5761t\00\0bMiddle Townt
 \00\0dMort Dufresnet\00\0c763 555 5765t\00\02MNt\00\11TriCounty Producet
 \00\0555432
DATA=END
> 

DbLoad

Loads a database from the output produced by DbDump. Options are:

-c

Specifies configuration options. The options supplied here override the corresponding options that appear in the data that is being loaded. This option takes values of the form name=value, where name is the configuration option that you are overriding and value is the new value for the option.

The following options can be specified:

  • database

    The name of the database to be loaded. This option duplicates the functionality of this command's -s command line option.

  • dupsort

    Indicates whether duplicates are allowed in the database. A value of true allows duplicates in the database.

-f

Identifies the file from which the database is to be loaded.

-n

Do not overwrite existing keys in the database when loading into an already existing database. If a key/data pair cannot be loaded into the database for this reason, a warning message is displayed on the standard error output, and the key/data pair are skipped

-h

Identifies the environment's directory. This parameter is required.

-l

Allows loading databases that were dumped with the Berkeley DB C product, when the dump file contains parameters not known to JE.

-s

Overrides the database name, causing the data to be loaded into a database that uses the name supplied to this parameter.

-T

Causes a flat text file to be loaded into the database.

The input must be paired lines of text, where the first line of the pair is the key item, and the second line of the pair is its corresponding data item.

A simple escape mechanism, where newline and backslash (\) characters are special, is applied to the text input. Newline characters are interpreted as record separators. Backslash characters in the text will be interpreted in one of two ways: If the backslash character precedes another backslash character, the pair will be interpreted as a literal backslash. If the backslash character precedes any other character, the two characters following the backslash will be interpreted as a hexadecimal specification of a single character; for example, \0a is a newline character in the ASCII character set.

For this reason, any backslash or newline characters that naturally occur in the text input must be escaped to avoid misinterpretation by db_load.

-v

Report periodic load status to the console.

-V

Prints the database version number and then quits. All other command line options are ignored.

For example:

> java com.sleepycat.je.util.DbDump -h . -s VendorDB -f vendordb.txt
> java com.sleepycat.je.util.DbLoad -h . -f vendordb.txt
> 

DbVerify

Examines the identified database for errors. Options are:

-h

Identifies the environment's directory. This parameter is required.

-q

Suppress the printing of any error descriptions. Instead, simply exit success or failure.

-s

Identifies the database to be verified. This parameter is required.

-V

Prints the database version number and then quits. All other command line options are ignored.

-v

Report intermediate statistics every N leaf nodes, where N is the value that you provide this parameter.

For example:

> java com.sleepycat.je.util.DbVerify -h . -s VendorDB

<BtreeStats>
<BottomInternalNodesByLevel total="1">
  <Item level="1" count="1"/>
</BottomInternalNodesByLevel>
<InternalNodesByLevel total="1">
  <Item level="2" count="1"/>
</InternalNodesByLevel>
<LeafNodes count="6"/>
<DeletedLeafNodes count="0"/>
<DuplicateCountLeafNodes count="0"/>
<MainTreeMaxDepth depth="2"/>
<DuplicateTreeMaxDepth depth="0"/>
</BtreeStats>