|
| 1 | +# Backup Management |
| 2 | + |
| 3 | +Our platform uses [Velero](https://velero.io/) for backup and recovery operations. Velero provides a simple and reliable way to back up and restore Kubernetes cluster resources and persistent volumes. |
| 4 | + |
| 5 | +## Automated Backups with Velero |
| 6 | + |
| 7 | +By default, Velero is configured to automatically back up specific namespaces every day at 02:00 UTC, with a retention policy of 7 days. The namespaces included in the default backup schedule are: |
| 8 | + |
| 9 | +- `harbor` |
| 10 | +- `vault` |
| 11 | + |
| 12 | +The backup schedule is defined in the following file: |
| 13 | + |
| 14 | +```markdown |
| 15 | +gitops-pipelines/delivery/clusters/cc-cluster/core-services/components/velero/backup-schedule.yaml |
| 16 | +``` |
| 17 | + |
| 18 | + |
| 19 | +### Customizing Backup Schedules |
| 20 | + |
| 21 | +To add more namespaces to the backup schedule or adjust the backup settings, you can update the existing `backup-schedule.yaml` file or create a new one. Changes made to this file will be detected by ArgoCD and applied automatically, ensuring your backups are always up to date. |
| 22 | + |
| 23 | +## Restoring from Backup |
| 24 | + |
| 25 | +In the event that you need to restore from a backup, follow the steps below. |
| 26 | + |
| 27 | +### Disable ArgoCD Auto-Sync |
| 28 | + |
| 29 | +Before initiating a restore, it's important to disable ArgoCD's auto-sync feature to prevent it from overwriting the restored resources. You can disable auto-sync by: |
| 30 | + |
| 31 | +- Editing the ArgoCD application manifest in the GitOps repository. |
| 32 | +- Using the ArgoCD UI. |
| 33 | +- Using the ArgoCD CLI. |
| 34 | + |
| 35 | +> **Recommended Approach:** Update the ArgoCD application file in the GitOps repository. This method ensures that changes are version-controlled and easily trackable. |
| 36 | +
|
| 37 | +### Install and Configure Velero Locally |
| 38 | + |
| 39 | +1. **Install Velero CLI:** |
| 40 | + |
| 41 | + Follow the [official Velero installation guide](https://velero.io/docs/main/basic-install/) to install the Velero CLI on your local machine. |
| 42 | + |
| 43 | +2. **Configure Cluster Context:** |
| 44 | + |
| 45 | + Ensure your kubeconfig is set to the cluster you wish to restore: |
| 46 | + |
| 47 | + ```bash |
| 48 | + kubectl config use-context <your-cluster-context> |
| 49 | + |
| 50 | +3. **Validate Velero Access:** |
| 51 | + |
| 52 | + Verify that Velero can communicate with your cluster: |
| 53 | + |
| 54 | + ```bash |
| 55 | + velero version |
| 56 | + ``` |
| 57 | + |
| 58 | + |
| 59 | +### Perform the Restore |
| 60 | + |
| 61 | +1. **List Available Backups:** |
| 62 | + |
| 63 | + View all available backups to find the one you need: |
| 64 | + |
| 65 | + ```bash |
| 66 | + velero backup get |
| 67 | + ``` |
| 68 | +2. **Initiate the Restore:** |
| 69 | + |
| 70 | + Use the following command to start the restore process:: |
| 71 | + |
| 72 | + ```bash |
| 73 | + velero restore create --from-backup <backup-name> |
| 74 | + ``` |
| 75 | + Replace <backup-name> with the name of the backup you wish to restore. For example: |
| 76 | + |
| 77 | + ```bash |
| 78 | + velero restore create --from-backup daily-backup-20241120020019 |
| 79 | + ``` |
| 80 | +3. **Monitor the Restore Process:** |
| 81 | + |
| 82 | + Check the status of the restore: |
| 83 | + |
| 84 | + ```bash |
| 85 | + velero restore get |
| 86 | + ``` |
| 87 | + For detailed information: |
| 88 | + ```bash |
| 89 | + velero restore describe <restore-name> |
| 90 | + ``` |
| 91 | + Replace <restore-name> with the name of the restore operation initiated. |
| 92 | + |
| 93 | +### Re-enable ArgoCD Auto-Sync |
| 94 | + |
| 95 | +After confirming that the restore was successful and the cluster is functioning as expected, re-enable ArgoCD's auto-sync feature to maintain the desired state of the cluster. |
| 96 | +
|
| 97 | +## Additional Considerations |
| 98 | +
|
| 99 | +- **Data Consistency:** Ensure that no conflicting operations are occurring during the restore to prevent data inconsistencies. |
| 100 | +- **Resource Quotas:** Verify that resource quotas and limits are sufficient for the restored resources. |
| 101 | +
|
| 102 | +## References |
| 103 | +
|
| 104 | +- [Velero Documentation](https://velero.io/docs/) |
| 105 | +- [ArgoCD Documentation](https://argo-cd.readthedocs.io/en/stable/) |
| 106 | +
|
| 107 | +--- |
| 108 | +
|
| 109 | +By following these steps, you can effectively manage backups and restores within your Kubernetes clusters, ensuring data integrity and continuity of service. |
0 commit comments