DB2 Version 9.7 for Linux, UNIX, and Windows

Performing a redirected restore operation

A redirected restore operation is performed when one of the following situations occur:
Note: A redirected restore cannot be used to move data from one operating system to another.

During a redirected restore operation, directory and file containers are automatically created if they do not already exist. The database manager does not automatically create device containers.

DB2 only supports adding, changing or removing table space containers of a DMS table space. For an SMS table space, redirected restore is the only method to modify the table space container configuration.

You can redefine table space containers by invoking the RESTORE DATABASE command and specifying the REDIRECT parameter, or by using the Restore Database wizard in the Control Center. The process for invoking a redirected restore of an incremental backup image is similar to the process for invoking a redirected restore of a non-incremental backup image. Issue the RESTORE DATABASE command with the REDIRECT option and specify the backup image that should be used for the incrementally restore of the database. Alternatively, you can generate a redirected restore script from a backup image, then you can modify the script as required. See Performing a redirected restore using an automatically generated script.

Container redirection provides considerable flexibility for managing table space containers. For example, even though adding containers to SMS table spaces is not supported, you could accomplish this by specifying an additional container when invoking a redirected restore operation.

Example 1

A redirected restore operation consists of a two-step database restore process with an intervening table space container definition step:
  1. Issue the RESTORE DATABASE command with the REDIRECT option.
  2. Use the SET TABLESPACE CONTAINERS command to define table space containers for the restored database (specifies the table space locations on the target system)
  3. Issue the RESTORE DATABASE command again, this time specifying the CONTINUE option.
The following example shows how to perform a redirected restore on database SAMPLE:
   db2 restore db sample redirect without prompting
   SQL1277W A redirected restore operation is being performed. 
   Table space configuration can now be viewed and table spaces that do not 
   use automatic storage can have their containers reconfigured.

   DB20000I The RESTORE DATABASE command completed successfully.

   db2 set tablespace containers for 2 using (path 'userspace1.0', path    
   'userspace1.1')
   DB20000I The SET TABLESPACE CONTAINERS command completed successfully.

   db2 restore db sample continue
   DB20000I The RESTORE DATABASE command completed successfully.

Example 2

Following is a typical non-incremental redirected restore scenario for a database whose alias is MYDB:
  1. Issue a RESTORE DATABASE command with the REDIRECT option.
       db2 restore db mydb replace existing redirect
  2. Issue a SET TABLESPACE CONTAINERS command for each table space whose containers you want to redefine. For example, in a Windows environment:
       db2 set tablespace containers for 5 using
              (file 'f:\ts3con1'20000, file 'f:\ts3con2'20000)                
    To verify that the containers of the restored database are the ones specified in this step, issue the LIST TABLESPACE CONTAINERS command for every table space whose container locations are being redefined.
  3. After successful completion of steps 1 and 2, issue:
       db2 restore db mydb continue

    This is the final step of the redirected restore operation.

  4. If step 3 fails, or if the restore operation has been aborted, the redirected restore can be restarted, beginning at step 1.
Note:
  1. After successful completion of step 1, and before completing step 3, the restore operation can be aborted by issuing:
       db2 restore db mydb abort
  2. If step 3 fails, or if the restore operation has been aborted, the redirected restore can be restarted, beginning at step 1.

Example 3

Following is a typical manual incremental redirected restore scenario for a database whose alias is MYDB and has the following backup images:
   backup db mydb
   Backup successful. The timestamp for this backup image is : <ts1>

   backup db mydb incremental
   Backup successful. The timestamp for this backup image is : <ts2>
  1. Issue a RESTORE DATABASE command with the INCREMENTAL and REDIRECT options.
       db2 restore db mydb incremental taken at <ts2> replace existing redirect
  2. Issue a SET TABLESPACE CONTAINERS command for each table space whose containers must be redefined. For example, in a Windows environment:
       db2 set tablespace containers for 5 using
              (file 'f:\ts3con1'20000, file 'f:\ts3con2'20000)
    To verify that the containers of the restored database are the ones specified in this step, issue the LIST TABLESPACE CONTAINERS command.
  3. After successful completion of steps 1 and 2, issue:
       db2 restore db mydb continue
  4. The remaining incremental restore commands can now be issued as follows:
       db2 restore db mydb incremental taken at <ts1>
       db2 restore db mydb incremental taken at <ts2>
    This is the final step of the redirected restore operation.
Note:
  1. After successful completion of step 1, and before completing step 3, the restore operation can be aborted by issuing:
       db2 restore db mydb abort
  2. After successful completion of step 3, and before issuing all the required commands in step 4, the restore operation can be aborted by issuing:
       db2 restore db mydb incremental abort
  3. If step 3 fails, or if the restore operation has been aborted, the redirected restore can be restarted, beginning at step 1.
  4. If either restore command fails in step 4, the failing command can be reissued to continue the restore process.

Example 4

Following is a typical automatic incremental redirected restore scenario for the same database:
  1. Issue a RESTORE DATABASE command with the INCREMENTAL AUTOMATIC and REDIRECT options.
       db2 restore db mydb incremental automatic taken at <ts2>
              replace existing redirect
  2. Issue a SET TABLESPACE CONTAINERS command for each table space whose containers must be redefined. For example, in a Windows environment:
       db2 set tablespace containers for 5 using
              (file 'f:\ts3con1'20000, file 'f:\ts3con2'20000)
    To verify that the containers of the restored database are the ones specified in this step, issue the LIST TABLESPACE CONTAINERS command.
  3. After successful completion of steps 1 and 2, issue:
       db2 restore db mydb continue
    This is the final step of the redirected restore operation.
Note:
  1. After successful completion of step 1, and before completing step 3, the restore operation can be aborted by issuing:
       db2 restore db mydb abort
  2. If step 3 fails, or if the restore operation has been aborted, the redirected restore can be restarted, beginning at step 1 after issuing:
       db2 restore db mydb incremental abort