Skip to main content
Version: 2.6

Configure and manage declarative backups and restores

Portworx Backup allows you to orchestrate backups and restore through declarative yaml manifests for your S3 compliant backup location. To achieve this task, you need to create an ApplicationBackup custom resource (CR) per cluster and apply this spec on all of your application clusters. You can even integrate this CR with GitOps pipelines and use the CR to trigger backups and restores.

To view the backups created through declarative yaml manifests in the Portworx Backup web console, you need to add the associated backup location in the web console. After some time, backups triggered through this mechanism appear in the All Backups page of the web console.

Prerequisite

  • Configure GitOps on application cluster(s)

Create a backup through CR

  1. Create a backup location CR, push it to GitHub repository and have Argo sync up this data on the required application cluster.

    S3 compliant backup location CR:

    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: BackupLocation
    metadata:
    name: <backup-location-name>
    namespace: <backup-namespace>
    annotations:
    stork.libopenstorage.org/skipresource: "true"
    location:
    type: s3
    path: <s3-bucket-path>
    s3Config:
    region: <s3-bucket-region>
    accessKeyID: <access-key>
    secretAccessKey: <secret-key>
    endpoint: <s3-end-point>
    disableSSL: false
    Backup location and S3 configuration parameters
    ParameterDescriptionValueRequired?
    backup-location-namePreferred name for backup locationDefault: NoneYes
    backup-namespacePreferred name for the namespace where the backup location need to be createdDefault: NoneYes
    s3-bucket-regionWhich region your s3 bucket is located inDefault: NoneYes
    access-keyYour object store's accessKeyIDDefault: NoneYes
    secret-keyYour object store's secretAccessKeyDefault: NoneYes
    endpointThe URL or IP address of your bucketDefault: NoneYes
    disableSSLWhether or not to disable SSLDefault: falseNo
  1. Create ApplicationBackup CR, push it to GitHub and have Argo sync up this data on the required application cluster.

     apiVersion: stork.libopenstorage.org/v1alpha1
    kind: ApplicationBackup
    metadata:
    annotations:
    portworx.io/created-by: "px-backup"
    name: <app-backup-CR-name>
    namespace: <backup-namespace>
    spec:
    backupLocation: <backup-location-name> (refer to BL CR created in step 1)
    namespaces: <backup-namespace>
    reclaimPolicy: Retain
    selectors:
    postExecRule:

    ApplicationBackup CR parameters

    ParameterDescriptionValueRequired?
    app-backup-CR-namePreferred name for the ApplicationBackup CRDefault: NoneYes
    backup-namespacePreferred namespace where the ApplicationBackup CR needs to be createdDefault: NoneYes
    backup-location-namePreferred name for the backup locationDefault: NoneYes
    backup-namespaceNamespace where the backup needs to be createdDefault: NoneYes
    reclaimPolicyReclaim policy of the PV createdDefault: DeleteYes
  2. Post ApplicationBackup creation, Portworx Backup creates the backup. You can track the status by checking the content of ApplicationBackup CR created in Step 2.

Restore a backup through CR

  1. From the s3 bucket path, fetch the metadata.json file. For example, here is the location from the previous backup:

     <bucket-name>/<namespace>/<application-backup-cr-name>/<application-backup-cr-uid>/metadata.json
    username-<backup-namespace>/<backup-namespace>/<backup-name>/<alphanumeric-application-cr-id>/metadata.json

    This file is a copy of the ApplicationBackup CR that is in a successful state.

    If you want to restore to a new namespace, edit the metadata.json file, replace namespace with the destination namespace:

    <destination namespace where restore is being performed>
  2. Apply the BackupLocation CR in the restore namespace.

  3. Apply the ApplicationRestore CR (copy of ApplicationBackup CR) in the restore namespace:

    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: ApplicationRestore
    metadata:
    name: <app-restore-CR-name>
    namespace: <restore-namespace>
    spec:
    backupName: <backup-name> (refer to CR name from metadata.json file)
    backupLocation: <s3-backup-location> (refer to backup location CR)
    namespaceMapping: <backup-namespace>:<restore-namespace> (mapping source namespace to destination namespace for restore)

    ApplicationRestore CR parameters

    ParameterDescriptionValueRequired?
    app-restore-CR-namePreferred name for the ApplicationRestore CRDefault: NoneYes
    restore-namespaceNamespace where the backup needs to be restoredDefault: NoneYes
    backup-nameName of the backup that needs to be restoreDefault: NoneYes
    s3-backup-locationS3 backup location of the backupDefault: NoneYes
    backup-namespaceNamespace where backup existsDefault:Yes
    restore-namespaceNamespace where the backup needs to be restoredDefault:Yes
  4. Check the status of the restore progress by scanning CR content.

View the Backups created through CR

  1. Access Portworx Backup web console.

  2. Login with the user credentials.

  3. From the home page, add backup location. Ensure that you provide the same credentials that you used during backup creation.

    All the backups created through CR get synced and appear in the web console after 15-30 minutes depending on the number of backups created in the S3 backup location.

    You can view all the backups created with this declarative method by navigating to All Backups page from the home page of Portworx Backup web console.

    note

    Users will not be able to view the custom resource restores in the Portworx Backup web console.

Was this page helpful?