Package org.h2.tools
Class Backup
- java.lang.Object
-
- org.h2.util.Tool
-
- org.h2.tools.Backup
-
public class Backup extends Tool
Creates a backup of a database. This tool copies all database files. The database must be closed before using this tool. To create a backup while the database is in use, run the BACKUP SQL statement. In an emergency, for example if the application is not responding, creating a backup using the Backup tool is possible by using the quiet mode. However, if the database is changed while the backup is running in quiet mode, the backup could be corrupt.
-
-
Constructor Summary
Constructors Constructor Description Backup()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidexecute(java.lang.String zipFileName, java.lang.String directory, java.lang.String db, boolean quiet)Backs up database files.static voidmain(java.lang.String... args)Options are case sensitive.private voidprocess(java.lang.String zipFileName, java.lang.String directory, java.lang.String db, boolean quiet)voidrunTool(java.lang.String... args)Run the tool with the given output stream and arguments.-
Methods inherited from class org.h2.util.Tool
isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, throwUnsupportedOption
-
-
-
-
Method Detail
-
main
public static void main(java.lang.String... args) throws java.sql.SQLExceptionOptions are case sensitive.Supported options are: [-help] or [-?] Print the list of options [-file <filename>] The target file name (default: backup.zip) [-dir <dir>] The source directory (default: .) [-db <database>] Source database; not required if there is only one [-quiet] Do not print progress information - Parameters:
args- the command line arguments- Throws:
java.sql.SQLException- on failure
-
runTool
public void runTool(java.lang.String... args) throws java.sql.SQLExceptionDescription copied from class:ToolRun the tool with the given output stream and arguments.
-
execute
public static void execute(java.lang.String zipFileName, java.lang.String directory, java.lang.String db, boolean quiet) throws java.sql.SQLExceptionBacks up database files.- Parameters:
zipFileName- the name of the target backup file (including path)directory- the source directory namedb- the source database name (null if there is only one database, and empty string to backup all files in this directory)quiet- don't print progress information- Throws:
java.sql.SQLException- on failure
-
process
private void process(java.lang.String zipFileName, java.lang.String directory, java.lang.String db, boolean quiet) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
-