public class DbDump
extends java.lang.Object
When using this utility as a command line program, and the application uses custom key comparators, be sure to add the jars or classes to the classpath that contain the application's comparator classes.
java { com.sleepycat.je.util.DbDump | -jar je-<version>.jar DbDump } -h <dir> # environment home directory [-f <fileName>] # output file, for non -rR dumps [-l] # list databases in the environment [-p] # output printable characters [-r] # salvage mode [-R] # aggressive salvage mode [-d] <directory> # directory for *.dump files (salvage mode) [-s <databaseName>] # database to dump [-v] # verbose in salvage mode [-V] # print JE version numberSee
main(java.lang.String[])
for a full description of the
command line arguments.
To dump a database to a stream from code:
DbDump dump = new DbDump(env, databaseName, outputStream, boolean); dump.dump();
Because a DATA=END
marker is used to terminate the dump of
each database, multiple databases can be dumped and loaded using a single
stream. The dump()
method leaves the stream positioned after
the last line written and the DbLoad.load()
method leaves the stream
positioned after the last line read.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
dbName |
protected boolean |
doAggressiveScavengerRun |
protected boolean |
doScavengerRun |
protected Environment |
env |
protected java.io.File |
envHome |
protected boolean |
formatUsingPrintable |
protected java.lang.String |
outputDirectory |
protected java.io.PrintStream |
outputFile |
protected boolean |
verbose |
Constructor and Description |
---|
DbDump(Environment env,
java.lang.String dbName,
java.io.PrintStream outputFile,
boolean formatUsingPrintable)
Create a DbDump object for a specific environment and database.
|
DbDump(Environment env,
java.lang.String dbName,
java.io.PrintStream outputFile,
java.lang.String outputDirectory,
boolean formatUsingPrintable)
Deprecated.
Please use the 4-arg ctor without outputDirectory instead.
|
Modifier and Type | Method and Description |
---|---|
void |
dump()
Perform the dump.
|
protected void |
dumpOne(java.io.PrintStream o,
byte[] ba,
boolean formatUsingPrintable) |
static void |
main(java.lang.String[] argv)
The main used by the DbDump utility.
|
protected void |
openEnv(boolean doRecovery) |
protected boolean |
parseArgs(java.lang.String[] argv) |
protected void |
printHeader(java.io.PrintStream o,
boolean dupSort,
boolean formatUsingPrintable) |
protected void |
printUsage(java.lang.String msg) |
protected java.io.File envHome
protected Environment env
protected java.lang.String dbName
protected boolean formatUsingPrintable
protected java.lang.String outputDirectory
protected java.io.PrintStream outputFile
protected boolean doScavengerRun
protected boolean doAggressiveScavengerRun
protected boolean verbose
@Deprecated public DbDump(Environment env, java.lang.String dbName, java.io.PrintStream outputFile, java.lang.String outputDirectory, boolean formatUsingPrintable)
public DbDump(Environment env, java.lang.String dbName, java.io.PrintStream outputFile, boolean formatUsingPrintable)
env
- The Environment containing the database to dump.dbName
- The name of the database to dump.outputFile
- The output stream to dump the database to.formatUsingPrintable
- true if the dump should use printable
characters.public static void main(java.lang.String[] argv) throws java.lang.Exception
argv
- The arguments accepted by the DbDump utility.
usage: java { com.sleepycat.je.util.DbDump | -jar je-<version>.jar DbDump } [-f output-file] [-l] [-p] [-V] [-s database] -h dbEnvHome [-rR] [-v] [-d directory]
This option recreates the Btree structure in memory, so as large a heap size as possible should be specified. If -r cannot be used due to insufficient memory, use -R instead.
When used on uncorrupted data files, this option should return equivalent data to a normal dump, but most likely in a different order; in other words, it should output a transactionally correct data set. However, there is one exception where not all committed records will be output:
The records for all databases are output. The records for each database are saved into <databaseName>.dump files in the current directory.
Unlike -r, the -R option does not recreate the Btree structure in memory. However, it does use a bit set to track all committed transactions, so as large a heap size as possible should be specified.
-R also differs from -r in that -R does not return a transactionally correct data set. This is because the Btree information is not reconstructed in memory. Therefore, data dumped in this fashion will almost certainly have to be edited by hand or other means before or after the data is reloaded. Be aware of the following abnormalities.
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.java.lang.Exception
protected void printUsage(java.lang.String msg)
protected boolean parseArgs(java.lang.String[] argv) throws java.io.IOException
java.io.IOException
protected void openEnv(boolean doRecovery) throws EnvironmentNotFoundException, EnvironmentLockedException
public void dump() throws EnvironmentNotFoundException, EnvironmentLockedException, DatabaseNotFoundException, java.io.IOException
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.java.io.IOException
- in subclasses.EnvironmentNotFoundException
EnvironmentLockedException
DatabaseNotFoundException
protected void printHeader(java.io.PrintStream o, boolean dupSort, boolean formatUsingPrintable)
protected void dumpOne(java.io.PrintStream o, byte[] ba, boolean formatUsingPrintable)
Copyright (c) 2002, 2017 Oracle and/or its affiliates. All rights reserved.