public class DbBackup
extends java.lang.Object
This class provides OO Tar backup-creation control. The extraction and listing features are implemented only in static fashion in the Main method, which provides a consistent interface for all three features from the command-line.
For tar creation, the default behavior is to fail if the target archive exists, and to abort if any database change is detected. Use the JavaBean setters to changes this behavior. See the main(String[]) method for details about command-line usage.
main(String[])
,
setOverWrite(boolean)
,
setAbortUponModify(boolean)
Constructor and Description |
---|
DbBackup(java.io.File archiveFile,
java.lang.String dbPath)
Instantiate a DbBackup instance for creating a Database Instance backup.
|
DbBackup(java.io.File archiveFile,
java.lang.String dbPath,
boolean script)
Used for SCRIPT backup
|
Modifier and Type | Method and Description |
---|---|
boolean |
getAbortUponModify() |
boolean |
getOverWrite() |
static void |
main(java.lang.String[] sa)
Command line invocation to create, examine, or extract HSQLDB database
backup tar archives.
|
void |
setAbortUponModify(boolean abortUponModify)
Defaults to true.
|
void |
setFileIgnore(java.lang.String fileExtension) |
void |
setOverWrite(boolean overWrite)
Defaults to false.
|
void |
setStream(java.lang.String fileExtension,
org.hsqldb.lib.InputStreamInterface is)
Overrides file with stream.
|
void |
write()
This method always backs up the .properties and .script files.
|
public DbBackup(java.io.File archiveFile, java.lang.String dbPath)
public DbBackup(java.io.File archiveFile, java.lang.String dbPath, boolean script)
public static void main(java.lang.String[] sa) throws java.io.IOException, org.hsqldb.lib.tar.TarMalformatException
This class stores tar entries as relative files without specifying parent directories, in what is commonly referred to as tar bomb format. The set of files is small, with known extensions, and the potential inconvenience of messing up the user's current directory is more than compensated by making it easier for the user to restore to a new database URL location at a peer level to the original.
Automatically calculates buffer sizes based on the largest component file (for "save" mode) or tar file size (for other modes).
Run
for syntax help.
java -cp path/to/hsqldb.jar org.hsqldb.lib.tar.DbBackup
java.io.IOException
org.hsqldb.lib.tar.TarMalformatException
public void setStream(java.lang.String fileExtension, org.hsqldb.lib.InputStreamInterface is)
public void setFileIgnore(java.lang.String fileExtension)
public void setOverWrite(boolean overWrite)
public void setAbortUponModify(boolean abortUponModify)
public boolean getOverWrite()
public boolean getAbortUponModify()
public void write() throws java.io.IOException, org.hsqldb.lib.tar.TarMalformatException
java.io.IOException
- for any of many possible I/O problemsjava.lang.IllegalStateException
- only if abortUponModify is set, and
database is open or is modified.org.hsqldb.lib.tar.TarMalformatException
Copyright �� 2001 - 2010 HSQL Development Group.