Bootstrap FreeKB - OpenShift - Restore OpenShift API for Data Protection (OADP) resources
OpenShift - Restore OpenShift API for Data Protection (OADP) resources

Updated:   |  OpenShift articles

This assumes you have already

For example, let's say you created a backup named my-project that stores resources in the namespace my-project in an Amazon Web Services (AWS) S3 Bucket.

~]$ oc get backups --namespace openshift-adp
NAME          AGE
my-project    102s

 

The aws s3api list-objects command can be used to list the objects in the S3 Bucket. Something like this should be returned, where there are my-project objects in the S3 Bucket. Awesome, it works!

~]$ aws s3api list-objects --bucket my-bucket-asdfadkjsfasfljdf --profile admin
{
    "Contents": [
        {
            "Key": "backups/my-project/my-project-csi-volumesnapshotclasses.json.gz",
            "LastModified": "2025-04-16T01:25:17+00:00",
            "ETag": "\"6848cb8d5f3669ef603f87e48ece8567\"",
            "Size": 29,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },
        {
            "Key": "backups/my-project/my-project-csi-volumesnapshotcontents.json.gz",
            "LastModified": "2025-04-16T01:25:17+00:00",
            "ETag": "\"6848cb8d5f3669ef603f87e48ece8567\"",
            "Size": 29,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },
        {
            "Key": "backups/my-project/my-project-csi-volumesnapshots.json.gz",
            "LastModified": "2025-04-16T01:25:17+00:00",
            "ETag": "\"6848cb8d5f3669ef603f87e48ece8567\"",
            "Size": 29,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },
        {
            "Key": "backups/my-project/my-project-itemoperations.json.gz",
            "LastModified": "2025-04-16T01:25:16+00:00",
            "ETag": "\"ae811dd04e417ed7b896b4c4fa3d2ac0\"",
            "Size": 27,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },
        {
            "Key": "backups/my-project/my-project-logs.gz",
            "LastModified": "2025-04-16T01:25:16+00:00",
            "ETag": "\"673aef92adf289811d5c04b270084eac\"",
            "Size": 11312,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },
        {
            "Key": "backups/my-project/my-project-resource-list.json.gz",
            "LastModified": "2025-04-16T01:25:16+00:00",
            "ETag": "\"47145873ba24f87182ee601bc7dd92fc\"",
            "Size": 307,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },
        {
            "Key": "backups/my-project/my-project-results.gz",
            "LastModified": "2025-04-16T01:25:16+00:00",
            "ETag": "\"4b8f571a28628df1f222ee56c3673550\"",
            "Size": 49,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },
        {
            "Key": "backups/my-project/my-project-volumeinfo.json.gz",
            "LastModified": "2025-04-16T01:25:16+00:00",
            "ETag": "\"05cd97096815e99b306792f280b67b06\"",
            "Size": 292,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },
        {
            "Key": "backups/my-project/my-project-volumesnapshots.json.gz",
            "LastModified": "2025-04-16T01:25:16+00:00",
            "ETag": "\"6848cb8d5f3669ef603f87e48ece8567\"",
            "Size": 29,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },        
        {
            "Key": "backups/my-project/my-project.tar.gz",
            "LastModified": "2025-04-16T01:25:16+00:00",
            "ETag": "\"c28c1d05c60cfb80f21799b5b11faac9\"",
            "Size": 13046,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        },
        {
            "Key": "backups/my-project/velero-backup.json",
            "LastModified": "2025-04-16T01:25:17+00:00",
            "ETag": "\"33c1cecb4d65267049037e13b78759d1\"",
            "Size": 3826,
            "StorageClass": "STANDARD",
            "Owner": {
                "DisplayName": "john.doe",
                "ID": "ab0e0a41e318d5103a77c82240d5cb3fc41ff11cc325c65b5c777a5f8e743743"
            }
        }
    ]
}        

 

Now let's see how to go about restoring from the backup. Let's delete my-deployment in namespace my-project.

oc delete deployment my-deployment --namespace my-project

 

And ensure there are now no deployments in my-project.

~]$ oc get deployments --namespace my-project
No resources found in my-project namespace

 

And no pods.

~]$ oc get pods --namespace my-project
No resources found in my-project namespace

 

Similar to the backup resource, let's create a restore resource. For example, let's say you have the following in a YAML file to create a resource to restore the resources in my-project.

]$ cat my-project-restore.yml
apiVersion: velero.io/v1
kind: Restore
metadata:
  name: my-project
  namespace: openshift-adp
spec:
  backupName: my-project
  includedResources: []
  namespaceMapping:
    my-project: my-project
  restorePVs: false

 

Let's use the oc apply command to create the restore resource.

~]$ oc apply --filename my-project-restore.yml
restore.velero.io/my-project created

 

Let's ensure the restore resource exists.

~]$ oc get restore --namespace openshift-adp
NAME          AGE
my-project    31s

 

If there are no issues, the Phase should be Completed, meaning the resources in my-project should have been restored from the backup in the backups location named "default".

]$ oc describe restore --namespace openshift-adp
Name:         my-project
Namespace:    openshift-adp
Labels:       <none>
Annotations:  <none>
API Version:  velero.io/v1
Kind:         Restore
Metadata:
  Creation Timestamp:  2025-04-22T01:16:54Z
  Finalizers:
    restores.velero.io/external-resources-finalizer
  Generation:        6
  Resource Version:  502671529
  UID:               131cc504-801b-4ff1-a8aa-76e7619041c9
Spec:
  Backup Name:  my-project
  Excluded Resources:
    nodes
    events
    events.events.k8s.io
    backups.velero.io
    restores.velero.io
    resticrepositories.velero.io
    csinodes.storage.k8s.io
    volumeattachments.storage.k8s.io
    backuprepositories.velero.io
  Included Resources:
    deployments
  Item Operation Timeout:  4h0m0s
  Namespace Mapping:
    my - project:  my-project
  Restore P Vs:     false
Status:
  Completion Timestamp:  2025-04-22T01:16:56Z
  Hook Status:
  Phase:  Completed
  Progress:
    Items Restored:  1
    Total Items:     1
  Start Timestamp:   2025-04-22T01:16:54Z
Events:              <none>

 

And the deployment in my-project should have been restored. Wow! It works.

]$ oc get deployment --namespace my-project
NAME            READY   UP-TO-DATE   AVAILABLE   AGE
my-deployment   1/1     1            1           3m25

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter b2d486 in the box below so that we can be sure you are a human.