Performing a redirected restore using an automatically generated script

When you perform a redirected restore operation, you must specify the locations of physical containers that are stored in the backup image and provide the complete set of containers for each table space that you are altering.

Before you begin

You can perform a redirected restore only if the database was previously backed up using the Db2® backup utility.

About this task

  • If the database exists, you must be able to connect to it in order to generate the script. Therefore, if the database requires an upgrade or crash recovery, this must be done before you attempt to generate a redirected restore script.
  • If you are working in a partitioned database environment, and the target database does not exist, you cannot run the command to generate the redirected restore script concurrently on all database partitions. Instead, the command to generate the redirected restore script must be run one database partition at a time, starting from the catalog partition.

    Alternatively, you can first create a dummy database with the same name as your target database. After the dummy database is created, you can then generate the redirected restore script concurrently on all database partitions.

  • Even if you specify the REPLACE EXISTING parameter when you issue the RESTORE DATABASE command to generate the script, the REPLACE EXISTING parameter is commented out in the script.
  • For security reasons, your password does not appear in the generated script. You need to enter the password manually.
  • The restore script includes the storage group associations for every table space that you restore.

Procedure

To perform a redirected restore using a script:

  1. Use the restore utility to generate a redirected restore script.
    The restore utility can be invoked through the command line processor (CLP) or the db2Restore application programming interface (API).
    The following is an example of the RESTORE DATABASE command with the REDIRECT parameter and the GENERATE SCRIPT parameter:
       db2 restore db test from /home/jseifert/backups taken at 20050304090733 
             redirect generate script test_node0000.clp
    This creates a redirected restore script on the client called test_node0000.clp.
  2. Open the redirected restore script in a text editor to make any modifications that are required.
    You can modify:
    • Restore options
    • Automatic storage paths
    • Container layout and paths
  3. Run the modified redirected restore script.
    For example:
       db2 -tvf test_node0000.clp