Velero is a convenient backup tool for Kubernetes clusters that compresses and backs up Kubernetes objects to object storage. It also takes snapshots of your cluster’s Persistent Volumes using your cloud provider’s block storage snapshot features, and can then restore your cluster’s objects and Persistent Volumes to a previous state.
Installing the Velero CLI
MacOS:
brew install velero
Linux:
INSTALL_PATH='/usr/local/bin'
wget -O velero.tar.gz https://github.com/vmware-tanzu/velero/releases/download/v1.9.2/velero-v1.9.2-linux-amd64.tar.gz
tar -xvf velero.tar.gz && cd velero-v1.9.2-linux-amd64 && mv velero $INSTALL_PATH && chmod +x ${INSTALL_PATH}/velero
Prerequisites
Before setting up the velero components, you will need to prepare your AWS/GCP object storage, secrets and a dedicated user with access to resources required to perform a backup. The instructions below will guide you.
velero schedule create daily-backups --schedule "0 7 * * *"
# Take initial backup
velero backup create --from-schedule daily-backup
# Get backup list
velero backup get
NAME STATUS ERRORS WARNINGS CREATED EXPIRES STORAGE LOCATION SELECTOR
daily-backup-20221004070030 Completed 0 0 2022-10-04 09:00:30 +0200 CEST 29d default <none>
daily-backup-20221003193617 Completed 0 0 2022-10-03 21:36:30 +0200 CEST 29d default <none>
Restore from backup
NOTE: Existing cluster resources will not be overwritten by the restoration process. To restore a PV delete it from the cluster before running the restore command