Copying a Db2 backup to a different instance or remote cluster

To copy a backup to a different instance, you need to compress your backup images and add them to the backup directory you want to restore from.

Before you begin

You must complete the following tasks:
  1. Backup a Db2® database offline. See Backing up a Db2 database offline for more details.
  2. Restore your backup by using the restore script. See Using the restore script for more details.

Procedure

  1. On the catalog node, compress your backup images and keystore with the following command:
    Important: You need to provide your keystore to be able to restore from a backup.
    su - db2inst1
    cd /backup_dir
    tar -cvzf backup_nnn.tgz -C /backup_dir/backup_nnn .
    
    # Examine the tar file and ensure it contains the backup images and keystore files
    tar -ztvf backup_nnn.tgz

    Perform an initial hash check with the following command and keep note of the output:

    sha1sum backup_nnn.tgz
  2. Exit the session and copy the tar locally using the following command:
    mkdir /local/backup/dir/backup_nnn
    oc rsync <db2 backup catalog pod>:/backup_dir/backup_nnn.tgz /local/backup/dir/backup_nnn

    You can now safely delete the backup tar you created on the backup instance.

  3. Copy the tar and add it to the backup directory of the instance you want to restore. Refer to the following example:
    oc rsync /local/backup/dir/backup_nnn <db2 restore catalog pod>:/backup_dir

    Perform another hash check with the following command:

    sha1sum backup_nnn.tgz

    Compare the output of this hash check with the output of the initial hash check and confirm they match.

    After confirming that the hash checks match, you can safely delete the backup tar you created on the backup instance.

  4. From the catalog node of the restored instance, extract the tar to the backup directory. Refer to the following example:
    su - db2inst1
    sudo tar -xvzf backup_dir/backup_nnn/backup_nnn.tgz -C backup_dir/backup_nnn

    You can now safely delete the backup tar you copied to the restore instance.

What to do next

Complete the steps to restore an external database. See Using the restore script for more details.