Breadcrumb

  1. Red Hat Interactive Learning Portal
  2. OpenShift learning
  3. Migrating applications from Red Hat OpenShift classic clusters to hosted control plane clusters
  4. Create a backup from the initial cluster

Migrating applications from Red Hat OpenShift classic clusters to hosted control plane clusters

Learn how you can migrate your applications from Red Hat OpenShift classic to a more modernized cluster.

After we have appropriately installed and configured OpenShift APIs for Data Protection (OADP) and DataProtectionApplication (DPA), we can now move forward with creating a backup of our cluster. 

Prerequisites:

  • DataProtectionApplication must be installed and reconciled.
  • BackupStorageLocation must be Available.

In this lesson, you will:

  • Create a backup.
  • Monitor and verify the backup you made.

Create a backup custom resource

To start, we’ll create a Backup custom resource to back up the application namespace, including PersistentVolumes (PV) . Optionally, you can verify before creating it. 

  1. Verify your OADP operator resources:

    oc get dpa -n openshift-adp
    oc get backupstoragelocation -n openshift-adp
  2. Create the backup using the following command: 

    cat <<EOF | oc apply -f -
    apiVersion: velero.io/v1
    kind: Backup
    metadata:
      name: cert-discovery-app-backup
      namespace: openshift-adp
    spec:
      includedNamespaces:
        - cert-discovery-app
      storageLocation: default
      ttl: 720h0m0s
      defaultVolumesToFsBackup: false
    EOF

    Each field corresponds to specific needs for various backup functions:

Field

Value

Description

includedNamespaces

cert-discovery-app

Namespaces to include in backup.

storageLocation

default

BackupStorageLocation name.

ttl

720h0m0s

Time to live (30 days).

Warning

Setting defaultVolumesToFsBackup: true is required when the storage provider is not compatible with any CSI driver (https://kubernetes-csi.github.io/docs/drivers.html), so that persistent volumes are backed up using File System Backup (FSB).

Note

If you're using the Alternative: Automated RBAC Backup approach from Prerequisites, use the modified Backup spec shown in that section instead. It includes includedClusterScopedResources and labelSelector to automatically backup ClusterRole and ClusterRoleBinding.

  1. Check the backup phase. This should progress from New to InProgress to Completed

    oc get backup cert-discovery-app-backup -n openshift-adp \
      -o jsonpath='{.status.phase}'

Note

If the backup fails or gets stuck, use oc oadp restore describe cert-discovery-app-restore -n openshift-adp to see detailed error messages.

  1. Wait for the backup to be completed. This could take up to fifteen minutes. 

    oc wait --for=jsonpath='{.status.phase}'=Completed \
      backup/cert-discovery-app-backup -n openshift-adp --timeout=15m

    Expected output:

    backup.velero.io/cert-discovery-app-backup condition met
  2. Next, you’ll verify the backup metadata exists:

    aws s3 ls s3://cert-discovery-management-app/management-export/backups/cert-discovery-app-backup/ --region eu-north-1

    As part of the results, you should see the following backup artifacts listed:

    1. cert-discovery-app-backup.tar.gz: Kubernetes resources
    2. cert-discovery-app-backup-logs.gz: Backup logs
    3. velero-backup.json: Backup metadata
  3. Verify Persistent Volume (PV) data in Kopia repository. Kopia writes the PV's contents as deduplicated, encrypted snapshots into a repository inside your backup storage bucket. This confirms Kopia created a repository for the namespace. This is where your PV data (SQLite database) is stored.

    aws s3 ls s3://cert-discovery-management-app/management-export/kopia/ --region eu-north-1

    Expected output:

    PRE cert-discovery-app/
  4. Optionally, we can verify the Kopia data exists by checking for the Kopia pack files that contain your database:

    aws s3 ls s3://cert-discovery-management-app/management-export/kopia/cert-discovery-app/ --region eu-north-1 | grep -E '^2026.*p[0-9a-f]'

 

You should see multiple files starting with p (pack files, ~20MB each). These are your database backup chunks. If so, you’re good to move on to getting your hosted cluster set up.

Previous resource
Install OADP on your management cluster
Next resource
Add and configure OADP on your hosted cluster