Restoring from a snapshot backup image

Restoring from a snapshot backup uses the fast copying technology of a storage device to perform the data copying portion of the restore.

Before you begin

To perform snapshot backup and restore operations, you need one of two things:
  • A Db2® ACS API driver for your storage device. For a list of supported storage hardware for the integrated driver, refer to this tech note.
  • For storage devices that are not supported, implement a custom script that allows your storage device to perform snapshot operations.

You must perform a snapshot backup before you can restore from a snapshot backup. See: Performing a snapshot backup.

Procedure

You can restore from a snapshot backup using the RESTORE DATABASE command with the USE SNAPSHOT parameter, or the db2Restore API with the SQLU_SNAPSHOT_MEDIA media type:
  • RESTORE DATABASE command:
    db2 restore db sample use snapshot
    
  • 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_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(db2Version900, &restoreStruct, &sqlca);
    
      return 0;
    }