Implications for restoring databases
The RESTORE DATABASE command is used to restore a database from a backup image.
During a restore operation it is possible to choose the location of the database path, and it is also possible to redefine the storage paths that are associated with the storage groups. The database path and the storage paths are set by using a combination of TO, ON, and DBPATH ON with the RESTORE DATABASE command, or using the SET STOGROUP PATHS command.
RESTORE DATABASE TEST1
RESTORE DATABASE TEST2 TO /db2/databases
RESTORE DATABASE TEST3 DBPATH ON /db2/databases
RESTORE DATABASE TEST3 ON /path1, /path2, /path3
RESTORE DATABASE TEST4 ON /path1, /path2 DBPATH ON /path3
- The database path (which is where the database manager
stores various control files for the database)
- If TO or DBPATH ON is specified, this indicates the database path.
- If ON is used but DBPATH ON is not specified with it, the first path listed with ON is used as the database path (in addition to it being a storage path).
- If none of TO, ON, or DBPATH ON is specified, the dftdbpath database manager configuration parameter determines the database path.
Note: If a database with the same name exists on disk, the database path is ignored, and the database is placed into the same location as the existing database. - The storage paths of each storage group (where the database manager creates automatic
storage table space containers)
- If ON is specified, all of the paths listed are considered storage paths, and these paths are used instead of the ones stored within the backup image. If the database contains multiple storage groups, every defined storage group uses the new storage group paths.
- If the SET STOGROUP PATHS command is used, the storage paths provided are used for the specified storage group instead of the ones stored within the backup image.
- If ON is not specified and the SET STOGROUP PATHS command is not used, the storage paths stored within the backup image are used.
| RESTORE DATABASE command | No database with the same name exists on disk | Database with the same name exists on disk | ||
|---|---|---|---|---|
| Database path | Storage paths | Database path | Storage paths | |
|
dftdbpath | Uses storage paths defined in the backup image | Uses database path of existing database | Uses storage paths defined in the backup image |
|
/db2/databases | Uses storage paths defined in the backup image | Uses database path of existing database | Uses storage paths defined in the backup image |
|
/db2/databases | Uses storage paths defined in the backup image | Uses database path of existing database | Uses storage paths defined in the backup image |
|
/path1 | All storage groups use /path1, /path2, /path3 for their storage paths | Uses database path of existing database | All storage groups use /path1, /path2, /path3 for their storage paths |
|
/path3 | All storage groups use /path1, /path2 for their storage paths | Uses database path of existing database | All storage groups use /path1, /path2 for their storage paths |
For those cases where storage paths have been redefined as part of the restore operation, the table spaces that are defined to use automatic storage are automatically redirected to the new paths. However, you cannot explicitly redirect containers associated with automatic storage table spaces using the SET TABLESPACE CONTAINERS command; this action is not permitted.
Use the -s option of the db2ckbkp command to show whether storage groups exist for a database within a backup image. The storage groups and their storage paths are displayed.
- The database must use the same set of storage paths on all database partitions.
- Issuing a RESTORE command with new storage paths can be done only on the catalog database partition, which sets the state of the database to RESTORE_PENDING on all non-catalog database partitions.
| RESTORE DATABASE command | Issued on database partition # | No database with the same name exists on disk | Database with the same name exists on disk (includes skeleton databases) | ||
|---|---|---|---|---|---|
| Result on other database partitions | Storage paths | Result on other database partitions | Storage paths | ||
RESTORE DATABASE TEST1 |
Catalog database partition | A skeleton database is created using the storage paths from the backup image on the catalog database partition. All other database partitions are placed in a RESTORE_ PENDING state. | Uses storage paths defined in the backup image | Nothing. Storage paths have not changed so nothing happens to other database partitions | Uses storage paths defined in the backup image |
| Non-catalog database partition | SQL2542N or SQL2551N is returned. If no database exists, the catalog database partition must be restored first. | N/A | Nothing. Storage paths have not changed so nothing happens to other database partitions | Uses storage paths defined in the backup image | |
RESTORE DATABASE TEST2
ON /path1, /path2, /path3 |
Catalog database partition | A skeleton database is created using the storage paths specified in the RESTORE command. All other database partitions are place in a RESTORE_ PENDING state. | All storage groups use /path1, /path2, /path3 for their storage paths | All storage groups use /path1, /path2, /path3 for their storage paths | |
| Non-catalog database partition | SQL1174N is returned. If no database exists, the catalog database partition must be restored first. Storage paths cannot be specified on the RESTORE of a non-catalog database partition. | N/A | SQL1172N is returned. New storage paths cannot be specified on the RESTORE of a non-catalog database partition. | N/A | |