Restoring container data

You can restore a persistent volume from a snapshot backup or a copy backup. A snapshot restore operation is generally the faster method for restoring a persistent volume.

Before you begin

For any type of restore, you cannot restore a volume to a different namespace.

You can restore a snapshot only to a new persistent volume. If you are restoring a snapshot, the persistent volume claim (PVC) for the new volume is automatically created when you restore the snapshot.

You can restore a copy backup to a new or original persistent volume. If you are restoring a copy backup to a new persistent volume, the PVC for the new volume is automatically created when you restore the copy backup. Except for the original location, the restore fails if you specify a PVC that already exists.

If you are restoring a copy backup to the original persistent volume, the application container to which the persistent volume is attached must not be running.

Restriction: To ensure that a restore request works correctly, do not manually delete any snapshots of volumes that are protected by Kubernetes Backup Support.

About this task

Depending on your recovery point objective and recovery time objective, you can run a fast restore, a copy restore, or a fast-ondemand restore operation.

The following scenarios can help you select the type of restore operation:
  • To rapidly restore a recent snapshot that was created as part of a schedule, run a fast restore operation. If another operation is in progress on the same volume, the fast restore operation might take longer to complete.
  • To restore a volume from a particular point in time after the corresponding snapshot has expired, run a copy restore operation to restore the copy backup from IBM Spectrum Protect Plus.
  • To restore a snapshot from an on-demand backup, run a fast-ondemand restore.
  • To verify a copy backup before it is restored to the original volume, you can run a copy restore operation to restore the copy backup to a new volume. Then, you can verify the contents of the new volume. If no issues are found in the new volume, you can restore the copy backup to the original volume.

Restore points are identified by the time stamp of the snapshot or copy backup.

Procedure

  1. To show the restore points that are available for a PVC, query all the backups for the PVC by running the following command:
    kubectl describe BaaSReq pvc_name -n namespace
  2. In the status output that is displayed, identify the time stamp of the source snapshot or copy backup that you want to restore. The time stamps are shown in the Status section of the output before the type of backup.

    For example, the following output shows the time stamps for different types of backups:

    Status:
     Timestamp:  2019-05-30 13:27:21
     Type:       FAST
     Timestamp:  2019-05-30 13:32:21
     Type:       COPY
     Timestamp:  2019-06-11 18:59:46
     Type:       FAST-ONDEMAND
    where:
    FAST
    Denotes the backup type for a snapshot backup that is taken during a scheduled backup operation.
    COPY
    Denotes the backup type for a copy backup that is stored on an IBM Spectrum Protect Plus vSnap server.
    FAST-ONDEMAND
    Denotes the backup type for an on-demand snapshot backup.
  3. Create a YAML file for the restore request that contains the following properties. Insert the time stamp for the source snapshot in the restorepoint parameter.
    #------------------------
    # Filename: filename.yaml
    #------------------------
    
    apiVersion: "baas.io/v1alpha1"
    kind: BaaSReq
    
    metadata:
      name: name_of_restore_request
      namespace: namespace
    spec:
      requesttype: restore
      pvcname: pvc_name
      targetvolume: target_volume_for_restore
      storageclass: storage_class_of_target_volume
      restorepoint: timestamp_of_backup
      restoretype: fast | copy | fast-ondemand
    where:
    filename
    The name of the YAML configuration file.
    name_of_restore_request
    The name of the request for the restore job. The name must be unique, and must not be the same as the name of the PVC.
    A new restore request must be created for each subsequent restore of the same PVC. In other words, if you want to restore a PVC again, create a new request and specify a different request name (name_of_request) in the YAML file.
    namespace
    The namespace for the request.
    pvc_name
    The name of the PVC that you want to restore.
    target_volume_for_restore
    The name of the PVC that you want to restore the volume to.
    For fast restores, the volume is always restored to a new PVC. In this case, provide the name of the new PVC.
    For copy restores, you can restore the volume to the original or new PVC. If you are restoring a copy backup to a new persistent volume, the PVC for the new volume is automatically created when you restore the copy backup. Except for the original location, the restore fails if you specify a PVC that already exists.
    storage_class_of_target_volume
    The storage class that is defined for the target volume.
    For fast restore operations, the storage class is ignored. The storage class of the original PVC is used.
    For copy restore operations, you can specify a storage class that is the same as the original PVC or specify a different storage class. If you do not specify the storage class, the storage class of the original PVC is used.
    If you specify a storage class but do not specify the restore type with the restoretype parameter, a copy restore is performed.
    timestamp_of_backup
    The time stamp of the source snapshot or copy backup that you want to restore from. The time stamp is in Coordinated Universal Time (UTC) format.
    If you do not specify a time stamp, the most recent snapshot or copy backup is restored.
    restoretype: fast | copy | fast-ondemand
    The type of restore operation to use.
    fast
    Restores a volume from a snapshot backup that was created as part of a scheduled backup.
    copy
    Restores a volume from a copy backup.
    fast-ondemand
    Restores a volume from an on-demand snapshot backup.
    This parameter is optional. If you do not specify a restore type, the type of restore is determined automatically. If a snapshot exists at the specified time stamp, a fast restore is run to restore the snapshot. If only a copy backup is available at the specified time, a copy restore is run to restore the copy backup.
  4. Start the restore request by entering the following command on the command line:
    kubectl create -f filename.yaml
    where filename is the name of the YAML configuration file.

What to do next

If you restored data to a new persistent volume, you can reconfigure the application container to mount the new volume after the snapshot or copy backup is restored.

As a best practice, delete the completed request by issuing the following command:
kubectl delete baasreq name_of_restore_request -n namespace
Deleting completed requests has the following benefits:
  • It reduces the size of the etcd database and allows you to reuse the name of a request for another operation.
  • It makes troubleshooting easier.
  • It makes it easier for you to track backup and restore requests that are running in your Kubernetes cluster.
  • At any point in time, you have a clear picture of requests that are running in on your cluster when you issue the following command:
    kubectl get baasreq -n namespace