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.
DbBackupMain#main(String[]), setOverWrite(boolean), setAbortUponModify(boolean)
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | |
| protected File | |
| pack-priv File[] | |
| pack-priv InputStreamInterface[] | |
| protected File | |
| pack-priv boolean[] | |
| pack-priv boolean[] | |
| protected String | |
| protected boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| pack-priv void | |
| protected static int | Returns: block valueNull array elements are permitted. They will just be
skipped by the algorithm. files)Return a 512-block buffer size suggestion, based on the size of what needs to be read or written, and default and typical JVM constraints. |
| protected static int | Returns: intFile file)Convenience wrapper for generateBufferBlockValue(File[]). |
| public boolean | |
| public boolean | |
| public void | |
| public void | |
| public void | |
| public void | setStream(String
String fileExtension, InputStreamInterface InputStreamInterface is)Overrides file with stream. |
| public void | |
| public void |
| abortUponModify | back to summary |
|---|---|
| protected boolean abortUponModify | |
| archiveFile | back to summary |
|---|---|
| protected File archiveFile | |
| componentFiles | back to summary |
|---|---|
| pack-priv File[] componentFiles | |
| componentStreams | back to summary |
|---|---|
| pack-priv InputStreamInterface[] componentStreams | |
| dbDir | back to summary |
|---|---|
| protected File dbDir | |
| existList | back to summary |
|---|---|
| pack-priv boolean[] existList | |
| ignoreList | back to summary |
|---|---|
| pack-priv boolean[] ignoreList | |
| instanceName | back to summary |
|---|---|
| protected String instanceName | |
| overWrite | back to summary |
|---|---|
| protected boolean overWrite | |
| DbBackup | back to summary |
|---|---|
| public DbBackup(File archiveFile, 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 | back to summary |
|---|---|
| public DbBackup(File archiveFile, String dbPath, boolean script) Used for SCRIPT backup | |
| checkEssentialFiles | back to summary |
|---|---|
| pack-priv void checkEssentialFiles() throws FileNotFoundException, IllegalStateException | |
| checkFilesNotChanged | back to summary |
|---|---|
| pack-priv void checkFilesNotChanged(long startTime) throws FileNotFoundException | |
| generateBufferBlockValue | back to summary |
|---|---|
| protected static int generateBufferBlockValue(File[] files) Return a 512-block buffer size suggestion, based on the size of what needs to be read or written, and default and typical JVM constraints. Algorithm details: Minimum system I want support is a J2SE system with 256M physical RAM. This system can hold a 61 MB byte array (real 1024^2 M). (61MB with Java 1.6, 62MB with Java 1.4). This decreases to just 60 MB with (pre-production, non-optimized) HSQLDB v. 1.9 on Java 1.6. Allow the user 40 MB of for data (this only corresponds to a much smaller quantity of real data due to the huge overhead of Java and database structures). This allows 20 MB for us to use. User can easily use more than this by raising JVM settings and/or getting more PRAM or VRAM. Therefore, ceiling = 20MB = 20 MB / .5 Kb = 40 k blocks We make the conservative simplification that each data file contains just one huge data entry component. This is a good estimation, since in most cases, the contents of the single largest file will be many orders of magnitude larger than the other files and the single block entry headers. We aim for reading or writing these biggest file with 10 reads/writes. In the case of READING Gzip files, there will actually be many more reads than this, but that's the price you pay for smaller file size.
| |
| generateBufferBlockValue | back to summary |
|---|---|
| protected static int generateBufferBlockValue(File file) Convenience wrapper for generateBufferBlockValue(File[]).
| |
| getAbortUponModify | back to summary |
|---|---|
| public boolean getAbortUponModify() | |
| getOverWrite | back to summary |
|---|---|
| public boolean getOverWrite() | |
| setAbortUponModify | back to summary |
|---|---|
| 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.
| |
| setFileIgnore | back to summary |
|---|---|
| public void setFileIgnore(String fileExtension) | |
| setOverWrite | back to summary |
|---|---|
| public void setOverWrite(boolean overWrite) Defaults to false. If arg is false, then attempts to write a tar file that already exist will abort.
| |
| setStream | back to summary |
|---|---|
| public void setStream(String fileExtension, InputStreamInterface is) Overrides file with stream.
| |
| write | back to summary |
|---|---|
| public void write() throws IOException, TarMalformatException This 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.
| |
| writeAsFiles | back to summary |
|---|---|
| public void writeAsFiles() throws IOException | |