Using a custom script allows you to restore snapshot backup images taken using storage
devices that are not supported by Db2® ACS.
Before you begin
You must have one of the following authorities: SYSADM,
SYSCTRL, or SYSMAINT.
About this task
A snapshot restore operation restores a snapshot backup.
You must use a custom script for that restore operation if your storage
device does not provide a vendor library.
During snapshot restore
operations, the protocol files that were written during the snapshot
backup are read. As well, a new protocol file is written for the restore
operation to show its progress. If the restore operation is successful,
the protocol file is deleted; if the operation fails, you can use
the protocol file to help investigate the cause of the failure.
A
restore operation restores the latest image that matches the specified time
stamp. For example, if there are two images for the time stamp 20121120, one
taken at 201211201000 and one taken at 201211202000, the last one
is chosen.
Restrictions
Procedure
To perform a snapshot restore:
-
Create a script that implements the Db2 ACS API.
- Initiate the restore operation using either
the RESTORE DATABASE command, the ADMIN_CMD procedure
with RESTORE DATABASE option, or the db2Restore API.
- RESTORE DATABASE command
RESTORE DATABASE dbname
USE SNAPSHOT SCRIPT path-to-script
OPTIONS 'path-to-repository'
TAKEN AT timestamp LOGTARGET INCLUDE
- ADMIN_CMD procedure
CALL SYSPROC.ADMIN_CMD
(restore database dbname
use snapshot script path-to-script
options 'path-to-repository'
taken at timestamp logtarget include)
- db2Restore API
int sampleRestoreFunction( char dbAlias[],
char restoredDbAlias[],
char user[],
char pswd[],
char workingPath[] )
{
db2MediaListStruct mediaListStruct = { 0 };
rmediaListStruct.locations = &workingPath;
rmediaListStruct.numLocations = 1;
rmediaListStruct.locationType = SQLU_SNAPSHOT_SCRIPT_MEDIA;
db2RestoreStruct restoreStruct = { 0 };
restoreStruct.piSourceDBAlias = dbAlias;
restoreStruct.piTargetDBAlias = restoredDbAlias;
restoreStruct.piMediaList = &mediaListStruct;
restoreStruct.piUsername = user;
restoreStruct.piPassword = pswd;
restoreStruct.iCallerAction = DB2RESTORE_STORDEF_NOINTERRUPT;
struct sqlca sqlca = { 0 };
db2Restore(db2Version1050, &restoreStruct, &sqlca);
return 0;
}