Backing Up Tanzu Application Service for Kubernetes
This topic provides an overview of how to manually back up Tanzu Application Service for Kubernetes (TAS for Kubernetes).
To back up TAS for Kubernetes automatically, see Backing Up TAS for Kubernetes Using Automation.
Overview
To back up TAS for Kubernetes:
Prerequisites
Before you back up TAS for Kubernetes, you must have configured back up and restore. See Configuring Back Up and Restore for TAS for Kubernetes.
Back Up TAS for Kubernetes
To back up TAS for Kubernetes Tanzu Postgres Instances:
Start a Velero back up:
velero create backup BACKUP-NAME \ --include-namespaces NAMESPACES \ --selector 'app in (RESOURCE-LIST)' \ --storage-location STORAGE-LOCATION \ --ttl TTL-LENGTH \ --wait
Where:
BACKUP-NAME
is the name to apply to the generated backup. VMware recommends using a backup name that includes a timestamp for ease of discoverability. For example:TAS4K8s_$(date -u +"%Y-%m-%dT%H:%M:%SZ")
.NAMESPACES
is the comma-delimited list of namespaces for the selected resources to back up.
The namespace list for backing up the default TAS for Kubernetes configuration ispostgres-dbs,cf-system
, wherepostgres-dbs
is the default TAS for Kubernetes database namespace.RESOURCE-LIST
is the comma-delimited list of selected resources to back up.
The resource list for backing up the default TAS for Kubernetes configuration ispostgres, cf-metadata
, wherecf-metadata
is specified for backing up the CF Metadata app, andpostgres
for backing up the TAS for Kubernetes Postgres instances.STORAGE-LOCATION
is the location where Velero should store the generated backup artifacts.- (Optional)
TTL-LENGTH
is the time to live (TTL) duration until the backup is deleted. The TTL should be formatted as hours, minutes, seconds:000H00M00S
. If you do not specify the TTL duration, the default duration length is720h0m0s
. - (Optional) Include the
--wait
parameter to follow the backup procedure progress.
The recommended command line is:
velero create backup BACKUP-NAME \ --include-namespaces postgres-dbs,cf-system \ --selector 'app in (postgres, cf-metadata)' \ --ttl 35040h0m0s \ --wait
Monitor Backup Progress
To monitor the progress of a running backup:
To determine the name of your backup:
velero get backups
For example:
$ velero get backups
NAME STATUS CREATED EXPIRES STORAGE LOCATION SELECTOR backup_1 Completed 2020-03-24 14:12:29 +0000 UTC 21d default (app in (cf-metadata,postgres)
To inspect a backup:
velero describe backup BACKUP-NAME
Where:
BACKUP-NAME
is the name you applied to your backup.- (Optional) Include the
--details
parameter to display a highly verbose output.
Review a Completed Backup
To review a completed backup:
Review Backup Logs
After a backup has completed, the backup logs can be reviewed for a detailed inspection of the root cause of potential failures.
To review the backup logs of a completed backup:
Run:
velero backup logs BACKUP-NAME
Where
BACKUP-NAME
is the name you applied to your backup.
Validate the Backup
To validate a completed backup by reviewing the Cloud Foundry data that was backed up:
If you do not have the TAS for Kubernetes installation resources:
- Download and extract the resources from VMware Tanzu Network. For more information, see Preparing Installation Resources.
- Inspect the TAS for Kubernetes artifact.
Confirm the
get-backup-metadata.sh
script is present in the following directory:tanzu-application-service/config/_ytt_lib/github.com/pivotal/cf-for-k8s-disaster-recovery/backup-metadata/bin
.
To confirm the name of the backup to validate:
velero get backups
For example:
$ velero get backups
NAME STATUS CREATED EXPIRES STORAGE LOCATION SELECTOR backup_1 Completed 2020-03-24 14:12:29 +0000 UTC 21d default (app in (cf-metadata,postgres)
To display a detailed inspection of the backup:
velero describe backup BACKUP-NAME
Where:
BACKUP-NAME
is the name you applied to your backup.- (Optional) Include the
--details
parameter to display a highly verbose output.
For example:
$ velero describe backup MY_BACKUP_NAME Name: tas4k8s-2020-10-13-09h17m49s Namespace: velero Labels: velero.io/storage-location=default Annotations: velero.io/source-cluster-k8s-gitversion=v1.17.9-gke.1504 velero.io/source-cluster-k8s-major-version=1 velero.io/source-cluster-k8s-minor-version=17+ Phase: Completed Errors: 0 Warnings: 0 Namespaces: Included: postgres-dbs, cf-system Excluded: <none> Resources: Included: * Excluded: <none> Cluster-scoped: auto Label selector: app in (cf-metadata,postgres) Storage Location: default Velero-Native Snapshot PVs: auto TTL: 35040h0m0s Hooks: <none> Backup Format Version: 1.1.0 Started: 2020-10-13 09:17:49 +0000 UTC Completed: 2020-10-13 09:18:46 +0000 UTC Expiration: 2024-10-12 09:17:49 +0000 UTC Total items to be backed up: 31 Items backed up: 31 Velero-Native Snapshots: 3 of 3 snapshots completed successfully (specify --details for more information)
To generate a JSON file which contains the snapshot of Cloud Foundry at the time of the backup:
tanzu-application-service/config/_ytt_lib/github.com/pivotal/cf-for-k8s-disaster-recovery/backup-metadata/bin/get-backup-metadata.sh BACKUP-NAME OUTPUT-FILENAME
Where
BACKUP-NAME
is the name you applied to your backup.OUTPUT-FILENAME
is the name of the Cloud Foundry state file to create for the backup. The created state file is a JSON formatted file.
For example:
tanzu-application-service/config/ytt_lib/github.com/pivotal/cf-for-k8s-disaster-recovery/backup-metadata/bin/get-backup-metadata.sh backup1 cf-metadata.json
To review the created Cloud Foundry outline, open the generated JSON file in your IDE of choice.
Troubleshoot a Failed Backup
To troubleshoot a failed backup, complete Review Backup Logs, and proceed accordingly.