Class DbBackup
- java.lang.Object
-
- org.hsqldb.lib.tar.DbBackup
-
public class DbBackup extends java.lang.ObjectWorks with tar archives containing HSQLDB database instance backups. Viz, creating, examining, or extracting these archives.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.
- Since:
- 2.0.0
- See Also:
-
The database backup section of the HyperSQL User Guide,
main(String[]),setOverWrite(boolean),setAbortUponModify(boolean)
-
-
Constructor Summary
Constructors 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
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleangetAbortUponModify()booleangetOverWrite()static voidmain(java.lang.String[] sa)Command line invocation to create, examine, or extract HSQLDB database backup tar archives.voidsetAbortUponModify(boolean abortUponModify)Defaults to true.voidsetFileIgnore(java.lang.String fileExtension)voidsetOverWrite(boolean overWrite)Defaults to false.voidsetStream(java.lang.String fileExtension, InputStreamInterface is)Overrides file with stream.voidwrite()This method always backs up the .properties and .script files.voidwriteAsFiles()
-
-
-
Constructor Detail
-
DbBackup
public DbBackup(java.io.File archiveFile, java.lang.String dbPath)Instantiate a DbBackup instance for creating a Database Instance backup. Much validation is deferred until the write() method, to prevent problems with files changing between the constructor and the write call.
-
DbBackup
public DbBackup(java.io.File archiveFile, java.lang.String dbPath, boolean script)Used for SCRIPT backup
-
-
Method Detail
-
main
public static void main(java.lang.String[] sa) throws java.io.IOException, TarMalformatExceptionCommand line invocation to create, examine, or extract HSQLDB database backup tar archives.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- Throws:
java.io.IOExceptionTarMalformatException
-
setStream
public void setStream(java.lang.String fileExtension, InputStreamInterface is)Overrides file with stream.
-
setFileIgnore
public void setFileIgnore(java.lang.String fileExtension)
-
setOverWrite
public void setOverWrite(boolean overWrite)
Defaults to false. If false, then attempts to write a tar file that already exist will abort.
-
setAbortUponModify
public void setAbortUponModify(boolean abortUponModify)
Defaults to true. If true, then the write() method will validate that the database is closed, and it will verify that no DB file changes between when we start writing the tar, and when we finish.
-
getOverWrite
public boolean getOverWrite()
-
getAbortUponModify
public boolean getAbortUponModify()
-
write
public void write() throws java.io.IOException, TarMalformatExceptionThis method always backs up the .properties and .script files. It will back up all of .backup, .data, and .log which exist. If abortUponModify is set, no tar file will be created, and this method will throw.- Throws:
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.TarMalformatException
-
writeAsFiles
public void writeAsFiles() throws java.io.IOException- Throws:
java.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG