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
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: falseBackup location and S3 configuration parameters
Parameter Description Value Required? backup-location-name Preferred name for backup location Default: None Yes backup-namespace Preferred name for the namespace where the backup location need to be created Default: None Yes s3-bucket-region Which region your s3 bucket is located in Default: None Yes access-key Your object store's accessKeyID Default: None Yes secret-key Your object store's secretAccessKey Default: None Yes endpoint The URL or IP address of your bucket Default: None Yes disableSSL Whether or not to disable SSL Default: false
No
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
Parameter Description Value Required? app-backup-CR-name Preferred name for the ApplicationBackup CR Default: None Yes backup-namespace Preferred namespace where the ApplicationBackup CR needs to be created Default: None Yes backup-location-name Preferred name for the backup location Default: None Yes backup-namespace Namespace where the backup needs to be created Default: None Yes reclaimPolicy Reclaim policy of the PV created Default: Delete Yes 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
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.jsonThis 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>
Apply the BackupLocation CR in the restore namespace.
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
Parameter Description Value Required? app-restore-CR-name Preferred name for the ApplicationRestore CR Default: None Yes restore-namespace Namespace where the backup needs to be restored Default: None Yes backup-name Name of the backup that needs to be restore Default: None Yes s3-backup-location S3 backup location of the backup Default: None Yes backup-namespace Namespace where backup exists Default: Yes restore-namespace Namespace where the backup needs to be restored Default: Yes Check the status of the restore progress by scanning CR content.
View the Backups created through CR
Access Portworx Backup web console.
Login with the user credentials.
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.
noteUsers will not be able to view the custom resource restores in the Portworx Backup web console.