Restoring Db2 data

To restore Db2® data from the vSnap repository, define a job that restores data from either the newest backup or an earlier backup copy. You can choose to restore data to the original instance or to an alternative instance on a different machine, and specify recovery options, and save the job.

Before you begin

Important: For all restore operations, Db2 must be at the same version level on the source and target hosts. In addition to that requirement, you must ensure that an instance with the same name as the instance that is being restored exists on each host. This requirement applies when the target instance has the same name, and when the names are different. In order for the restore operation to succeed, both instances must be provisioned, one with original name and the other with the new name.

If your Db2 environment includes partitioned databases, the data of all partitions is backed up during regular backup jobs. All instances are listed in the backup pane. Multi-partitioned instances are shown with partition numbers and host names.

Before you create a restore job for Db2, ensure that the following requirements are met:
  • At least one Db2 backup job is set up and running successfully. For instructions about setting up a backup job, see Backing up Db2 data.
  • IBM Spectrum® Protect Plus roles and resource groups are assigned to the user who is setting up the restore job. For more information about assigning roles, see Managing user access.
  • When restoring from a IBM Spectrum Protect archive, files will be migrated to a staging pool from the tape prior to the job beginning. Depending on the size of the restore, this process could take several hours.
  • Restore jobs can create data in the IBM Db2 log directory. In some cases, if more than one restore job is run, data will remain in the log directory from the previous job. As a result, the next attempt to restore a database to the original location fails unless the log directory is purged.

    For example, if the Db2 log directory is empty and a restore job runs with the options Restore to original instance, Overwrite existing databases, and Recover until end of backup, the restore job is successfully completed. If the job is followed by a second job with the options Restore to original instance, Overwrite existing databases, and Recover until end of available logs, this second restore attempt fails because the original restore job left data in the Db2 log directory.

Note: When you are restoring multi-partitioned databases to an alternative location, ensure that the target instance is configured with the same partition numbers as the original instance. All of those partitions must be on a single host. When you are restoring data to a new instance that is renamed, both instances instances required for the restore operation must be configured with the same number of partitions.

Before you start a restore operation to an alternative instance, ensure that the file system structure on the source machine is matched on the target machine. This file system structure includes table spaces, online logs, and the local database directory. Ensure that dedicated volumes with sufficient space are allocated to the file system structure. Db2 must be at the same version level on the source and target hosts for all restore operations, and an instance of the same name must exist on each host. For more information about space requirements, see Space requirements for Db2 protection. For more information about prerequisites and setup, see Prerequisites for Db2.

Procedure

  1. In the navigation pane, expand Manage Protection > Applications > Db2 and click Create job > Restore.
    The Rrestore wizard opens.
  2. Optional: If you started the restore wizard from the Jobs and Operations page, click Db2 as the source type and click Next.
    Tips:
    • For a running summary of your selections in the wizard, click Preview Restore in the navigation pane in the wizard.
    • The wizard is opened in the default setup mode. To run the wizard in advanced setup mode, select Advanced Setup. With advanced setup mode, you can set more options for your restore job.
  3. On the Select source page, click a Db2 instance to show the databases in that instance. Choose a database by clicking the plus icon Add to restore list icon for that database name. Click Next to continue.
  4. In the Source snapshot page, choose the type of restore operation required.
    • On-Demand: Snapshot: creates a once-off restore operation from a database snapshot. The job is not set to recur.
    • On-Demand: Point-in-Time: creates a once-off restore operation from a point-in-time backup of the database. The job is not set to recur.
    • Recurring: creates a recurring job that runs on a schedule and repeats.
    Tip:

    For an On-Demand: Snapshot you can select no recovery or to recover until the end of the backup. For an On-Demand: Point in Time restore job you can select to recover until the end of the available logs, or recover until a specific point-in-time.

  5. Complete the fields on the Source snapshot page and click Next to continue.
    The fields that are shown depend on the number of items that were selected on the Select source page and on the restore type. Some fields are also not shown until you select a related field.

    Fields that are shown for an on-demand snapshot, single resource restore

    Option Description
    Date range Specify a range of dates to show the available snapshots within that range.
    Backup storage type All backups in the selected date range are listed in rows that show the time that the backup operation occurred and the service level agreement (SLA) policy for the backup. Select the row that contains the backup time and SLA policy that you want, and then take one of the following actions:
    • Click the backup storage type that you want to restore from. The storage types that are shown depend on the types that are available in your environment and are shown in the following order:
      Backup
      Restores data that is backed up to a vSnap server.
      Replication
      Restores data that is replicated to a vSnap server.
      Object Storage
      Restores data that is copied to a cloud service or to a repository server.
      Archive
      Restores data that is copied to a cloud service archive or to a repository server archive (tape).
    • Click anywhere on the row. The first backup type that is shown sequentially from the left of the row is selected by default. For example, if the storage types Backup, Replication, and Archive are shown, Backup is selected by default.
    Use alternate vSnap server for the restore job If you are restoring data from a cloud service or a repository server, select this box to specify an alternative vSnap server, and then select a server from the Select alternate vSnap menu.

    When you restore data from a restore point that was copied to a cloud resource or repository server, a vSnap server is used as a gateway to complete the operation. By default, the vSnap server that is used to complete the restore operation is the same vSnap server that is used to complete the backup and copy operations. To reduce the load on the vSnap server, you can select an alternative vSnap server to serve as the gateway.

    Fields that are shown for an on-demand snapshot, multiple resources restore; point-in-time restore; or recurring restore

    Option Description
    Restore Location Type Select a type of location from which to restore data:
    Site
    The site to which snapshots were backed up. The site is defined in the System Configuration > Site pane.
    Cloud service
    The cloud service to which snapshots were copied. The cloud service is defined in the System Configuration > Backup Storage > Object Storage pane.
    Repository server
    The repository server to which snapshots were copied. The repository server is defined in the System Configuration > Backup Storage > Repository Server pane.
    Cloud service archive
    The cloud archive service to which snapshots were copied. The cloud service is defined in the System Configuration > Backup Storage > Object Storage pane.
    Repository server archive
    The repository server to which snapshots were copied to tape. The repository server is defined in the System Configuration > Backup Storage > Repository Server pane.
    Select a location If you are restoring data from a site, select one of the following restore locations:
    Primary
    The primary site from which to restore snapshots.
    Secondary
    The secondary site from which to restore snapshots.

    If you are restoring data from a cloud or repository server, select a server from the Select a location menu.

    Date selector For on-demand restore operations, specify a range of dates to show the available snapshots within that range.
    Restore Point For on-demand restore operations, select a snapshot from the list of available snapshots in the selected date range.
    Use alternate vSnap server for the restore job If you are restoring data from a cloud service or a repository server, select this box to specify an alternative vSnap server, and then select a server from the Select alternate vSnap menu.

    When you restore data from a restore point that was copied to a cloud service or repository server, a vSnap server is used as a gateway to complete the operation. By default, the vSnap server that is used to complete the restore operation is the same vSnap server that is used to complete the backup and copy operations. To reduce the load on the vSnap server, you can select an alternative vSnap server to serve as the gateway.

  6. Choose a restore method appropriate for the destination chosen for the restore operation. Click Next to continue.
    • Instant Access: In this mode, no further action is taken after IBM Spectrum Protect Plus mounts the volume from the vSnap repository. Use the data for custom recovery from the files in the mounted volume.
    • Production: In this mode, the Db2 application server first copies the files from the vSnap repository volume to the target host, which is either an alternative location or the original instance. That copied data is then used to start the database.
    • Test: In this mode, the agent creates a new database by using the data files directly from the vSnap repository.
    • Add a database name when you are restoring the database to a different location and you want to rename the database.
    Tip:

    Production is the only restore method that is available for restore operations to the original location. Any options not appropriate for the restore operation that you selected are not selectable.

    To restore data to the original instance, follow the instructions in Restoring to the original instance. To restore data to an alternative instance, follow the instructions in Restoring to an alternate instance.

  7. Set the destination for the restore operation by choosing one of the following options. Click Next to continue.
    • Restore to original instance: this option restores data to the original server and original instance.
    • Restore to alternate instance: this option restores data to a different specified location, creating a copy of the data at that location.

    If you are restoring data to an alternative location, choose an instance in the Instance table before you click Next. The alternative instance must be on a different machine; unsuitable instances are not available for selection. For multi-partition databases, the target instance must have the same set of partitions on a single machine.

  8. Optional: In the Job Options page, select the recovery, application, and advanced options for the restore operation you are defining.
    Tip:

    Recovery options are not available for instant access restore jobs.

    • No Recovery. This option skips any rollforward recovery after the restore operation. The database remains in a Rollforward pending state until you decide whether you want to run the rollforward operation manually.
    • Recover until end of backup. This option recovers the selected database to its state at the time the backup was created. The recovery process uses the log files that are included in the Db2 database backup.
    • Recover until end of available logs. This option is available only if the logs are backed up in the Db2 backup job definition. IBM Spectrum Protect Plus uses the latest restore point. A temporary restore point for log backups is created automatically so that the Db2 database can be rolled forward to the end of the logs. This recovery option is not available if you selected a specific restore point from the list. This option is available only when you are running an on-demand point-in-time restore job which uses the latest backup.
    • Recover until specific point-in-time. This option includes all the backup data up to a specific point-in-time. This option is available only if you enabled log backups in your Db2 backup job definition. Configure a point-in-time recovery by a specific date and time, for example, Jan 1, 2019 12:18:00 AM. IBM Spectrum Protect Plus finds the restore points directly before and after the selected point-in-time. During the recovery process, the older data backup volume and the newer log backup volume are mounted. If the point-in-time is after the last backup, a temporary restore point is created. This recovery option is not available if you selected a specific restore point from the list. This option is available only when you are running an on-demand point-in-time restore job that uses the newest backup.
    Tip: To skip optional steps in the restore wizard, select Skip optional steps and click Next.
  9. Optional: In the Job Options page, select the application options for the restore operation you are defining.
    Tip:

    Application options are not available for instant access restore jobs.

    • Overwrite existing databases. Choose this option to replace existing databases that have the same names during the restore recovery process. If this option is not selected, the restore job fails when databases with the same name are found during the restore operation. If you select this option, ensure that the Db2 log directory and the Db2 mirror log directory have no data.
      Attention: Ensure that no other databases share the local database directory as the original database or that data is overwritten when this choice is selected.
    • Maximum Parallel Streams per Database. You can choose to run the restore operation of data in parallel streams. This option is useful if you are restoring a large database.
    • Specify the size of the Db2 database memory set in KB. Specify the memory, in KB, to be allocated for the database restore on the target machine. This value is used to modify the shared memory size of the Db2 database on the target server. To use the same shared memory size at both the source server and the target server, set the value to zero.
  10. Optional: In the Job Options page, select the advanced options for the restore operation you are defining.
    • Run cleanup immediately on job failure. This option enables the automatic cleanup of backup data as part of a restore if recovery fails. This option is selected by default. Do not clear this option unless instructed by IBM® Support for troubleshooting purposes.
    • Continue with restores of other selected databases even if one fails. This option continues the restore operation if one database in the instance fails to be restored successfully. The process continues for all other databases that are being restored. When this option is not selected, the restore job stops when the recovery of a resource fails.
    • Mount point prefix. For instant access restore operations, specify the prefix for the path where the mount point is to be directed.
  11. Optional: Choose script options in the Apply Scripts page, and click Next to continue.
    • Select Pre-Script to select an uploaded script, and an application or script server where the pre-script runs. To select an application server where the script runs, clear the Use Script Server check box. Go to the System Configuration > Script page to configure scripts and script servers.
    • Select Post-Script to select an uploaded script and an application or script server where the post-script runs. To select an application server where the script runs, clear the Use Script Server check box. Go to the System Configuration > Script page to configure scripts and script servers.
    • Select Continue job/task on script error to continue running the job when the script that is associated with the job fails. When this option is enabled and the prescript completes with a nonzero return code, the backup or restore job continues to run and the prescript task status returns COMPLETED. If a postscript completes with a nonzero return code, the postscript task status returns COMPLETED. When this option is not selected, the backup or restore job does not run, and the prescript or postscript task status returns with a FAILED status.
  12. In the Schedule page, name the restore job and choose the frequency for the job to run. Schedule the start time, and click Next to continue.

    If the restore job you are specifying is an on-demand job, there is no option to enter a schedule. Specify a schedule only for recurrent restore jobs.

  13. In the Review page, review your selections for the restore job. If all the details are correct for your restore job, click Submit, or click Back to make amendments.

Results

A few moments after you click Submit, the onDemandRestore record is added to the Job Sessions pane. To view progress of the restore operation, expand the job. You can also download the log file by clicking the download icon the add to restore list  icon. All running jobs are viewable in the Jobs and Operations Running Jobs page.

To restore data to the original instance, follow the instructions in Restoring to the original instance. To restore data to an alternative instance, follow the instructions in Restoring to an alternate instance.