background image
<< Backing up encrypted databases | Enabling log archival mode >>

Creating a database from a backup copy

<< Backing up encrypted databases | Enabling log archival mode >>
Derby Server and Administration Guide
64
If a database with the same name exists in the derby.system.home location, the system
will delete the database, copy it from the backup location, and then restart it.
The log files are copied to the same location they were in when the backup was taken.
You can use the
logDevice
attribute in conjunction with the
restoreFrom=Path
attribute to store logs in a different location.
For example, to restore the sample database by using a backup copy in
c:\mybackups\sample
, the connection URL should be:
jdbc:derby:sample;restoreFrom=c:\mybackups\sample
For more information, see "restoreFrom=path attribute" in the Derby Reference Manual.
Creating a database from a backup copy
To create a database from a full backup copy at a specified location, specify the
createFrom=Path
attribute in the boot time connection URL.
If there is already a database with the same name in derby.system.home, an error will
occur and the existing database will be left intact. If there is not an existing database
with the same name in the current derby.system.home location, the system will copy the
whole database from the backup location to derby.system.home and start it.
The log files are also copied to the default location. You can use the
logDevice
attribute
in conjunction with the
createFrom=Path
attribute to store logs in a different location.
With the
createFrom=Path
attribute, you do not need to copy the individual log files to
the log directory.
For example, to create the sample database from a backup copy in
c:\mybackups\sample
, the connection URL should be:
jdbc:derby:sample;createFrom=c:\mybackups\sample
For more information, see "createFrom=path attribute" in the Derby Reference Manual.
Roll-forward recovery
Derby supports roll-forward recovery to restore a damaged database to the most recent
state before a failure occurred.
Derby restores a database from full backup and replays all the transactions after the
backup. All the log files after a backup are required to replay the transactions after the
backup. By default, the database keeps only logs that are required for crash-recovery.
For roll-forward recovery to be successful, all log files must be archived after a backup.
Log files can be archived using the backup function calls that enable log archiving.
In roll-forward recovery the log archival mode ensures that all old log files are available.
The log files are available only from the time that the log archival mode is enabled.
Derby uses the following information to restore the database:
· The backup copy of the database
· The set of archived logs
· The current online active log
You cannot use roll-forward recovery to restore individual tables. Roll-forward recovery
recovers the entire database.
To restore a database by using roll-forward recovery, you must already have a backup
copy of the database, all the archived logs since the backup was created, and the active
log files. All the log files should be in the database log directory.