background image
<< Unlogged Operations | Creating a database from a backup copy >>

Backing up encrypted databases

<< Unlogged Operations | Creating a database from a backup copy >>
Derby Server and Administration Guide
63
To use operating system commands for online database backups, call
the SYSCS_UTIL.SYSCS_FREEZE_DATABASE system procedure. The
SYSCS_UTIL.SYSCS_FREEZE_DATABASE system procedure puts the database into
a state in which it can be safely copied. After the database has been copied, use the
SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE system procedure to continue working
with the database. Only after SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE has
been specified can transactions once again write to the database. Read operations can
proceed while the database is "frozen."
Note: To ensure a consistent backup of the database, Derby might block applications
that attempt to write to a frozen database until the backup is completed and the
SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE system procedure is called.
The following example demonstrates how the freeze and unfreeze procedures are used
to surround an operating system copy command:
public static void backUpDatabaseWithFreeze(Connection conn)
throws SQLException
{
Statement s = conn.createStatement();
s.executeUpdate(
"CALL SYSCS_UTIL.SYSCS_FREEZE_DATABASE()");
//copy the database directory during this interval
s.executeUpdate(
"CALL SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()");
s.close();
}
When the log is in a non-default location
Note: Read
Logging on a separate device
to find out about the default location of the
database log.
If you put the database log in a non-default location prior to backing up the database, be
aware of the following requirements:
· If you are using an operating system command to back up the database, you must
explicitly copy the log file as well, as shown in the following example:
xcopy d:\mydatabases\sample c:\mybackups\2005-06-01\sample /s /i
xcopy h:\janet\tourslog\log c:\mybackups\2005-06-01\sample\log /s /i
If you are not using Windows, substitute the appropriate operating system command for
copying a directory and all of its contents to a new location.
· Edit the logDevice entry in service.properties of the database backup so that it
points to the correct location for the log. In the previous example, the log was
moved to the default location for a log, so you can remove the logDevice entry
entirely, or leave the logDevice entry as is and wait until the database is restored to
edit the entry.
See
Logging on a separate device
for information about putting the log in a non-default
location.
Backing up encrypted databases
When you back up an encrypted database, both the backup and the log files remain
encrypted.
To restore an encrypted database, you must know the boot password.
Restoring a database from a backup copy
To restore a database by using a full backup from a specified location, specify the
restoreFrom=Path
attribute in the boot time connection URL.