Using Velero with Portworx
Velero is a utility for managing disaster recovery, specifically for your Kubernetes cluster resources and persistent volumes. To take snapshots of Portworx volumes through Velero you need to install and configure the Portworx plugin.
Install Velero Plugin
Run the following command to install the Portworx plugin for Velero:
velero plugin add portworx/velero-plugin:1.0.2
This should add an init container to your Velero deployment to install the plugin.
Configure Velero to use Portworx snapshots
Once the plugin is installed, you need to create VolumeSnapshotLocation objects for Velero to use when taking volume snapshots. These specify whether you want to take local or cloud snapshots.
velero snapshot-location create portworx-local --provider portworx.io/portworx # credId is optional, required only if Portworx is configured with more than one credential. velero snapshot-location create portworx-cloud --provider portworx.io/portworx --config type=cloud,credId=<UUID>
After applying the above specs you should see them when you list the VolumeSnapshotLocaions
kubectl get volumesnapshotlocation -n velero
NAME AGE portworx-cloud 54m portworx-local 54m
Once the plugin has been installed and configured, everytime you take backups using Velero and include PVCs, it will also take Portworx snapshots of your volumes.
To backup all your apps in the default namespace and also create local snapshots
of the volumes, you would use
portworx-local for the snapshot location:
velero backup create default-ns-local-backup --include-namespaces=default --snapshot-volumes \ --volume-snapshot-locations portworx-local
Backup request "default-ns-local-backup" submitted successfully. Run `velero backup describe default-ns-local-backup` for more details.
To backup all your apps in the default namespace and also create cloud backups
of the volumes, you would use
portworx-cloud for the snapshot location:
velero backup create default-ns-cloud-backup --include-namespaces=default --snapshot-volumes \ --volume-snapshot-locations portworx-cloud
Backup request "default-ns-cloud-backup" submitted successfully. Run `velero backup describe default-ns-cloud-backup` for more details.
Once the specs and volumes have been backed up you should see the backup marked
Completed in velero.
velero get backup
NAME STATUS CREATED EXPIRES STORAGE LOCATION SELECTOR default-ns-local-backup Completed 2018-11-11 20:10:45 +0000 UTC 29d default <none> default-ns-cloud-backup Completed 2018-11-11 20:15:45 +0000 UTC 29d default <none>
Restoring from backups
When restoring from backups, a clone volume will be created from the snapshot and bound to the restored PVC. To restore from the backup created above you can run the following command:
velero restore create --from-backup default-ns-local-backup
Restore request "default-ns-local-backup-20181111201245" submitted successfully. Run `velero restore describe default-ns-local-backup-20181111201245` for more details.