considering argocd for backups
Check scripts syntax / check-scripts-syntax (push) Successful in 13s
Test Kubernetes backup scripts / test-k3s-control-plane-config-backup (push) Successful in 14s
Test Kubernetes backup scripts / test-automated-nfs-backup (push) Successful in 14s

This commit is contained in:
2026-09-07 16:18:19 -03:00
parent 75e888806f
commit 65fc9b3b9e
5 changed files with 164 additions and 37 deletions
+7 -4
View File
@@ -13,10 +13,12 @@ Behavior:
- `kube-system`, `kube-public`, and `kube-node-lease` are excluded from scale actions by default.
- Unmapped or excluded folder: copied to local staging without Kubernetes scale actions.
- Mapped folder: saves replicas, scales selected workloads down, waits, copies the quiesced folder to local staging, restores replicas, and waits again.
- After every folder has been processed, one `7z` invocation compresses the complete run staging directory. Workloads are therefore restored before compression starts.
- Per-run replica state and staged data are removed on exit. The staging parent is retained.
- Scale-down issues are warnings by policy (backup still runs).
- Restore issues are warnings by policy (run can still complete successfully).
- When `argocd` exists, its Deployments and StatefulSets are saved and scaled to zero first, even if excluded or lacking a source folder. The script waits for its pods to disappear and restores ArgoCD last, after compression or during exit cleanup.
- After every folder has been processed, one `7z` invocation compresses the complete run staging directory. Other workloads are restored before compression starts.
- Failed state capture or scaling aborts the run. Failed restoration is retried at exit; unrecovered replica state is retained and the run exits nonzero. INT and TERM also trigger restoration; forced termination or host failure requires manual recovery from saved state.
- Staged data is removed on exit. The staging parent and lock file are retained. Runs sharing `TMP_STATE_DIR` cannot overlap (`flock` required); use the same state directory for all invocations targeting the cluster.
- Existing archive paths are rejected; 7z warnings count as failures. Output, state and staging directories must be outside the source tree.
- Other reconcilers (such as operators and HPAs) and writers outside selected workload kinds are not suspended. Ordinary namespaces use a fixed shutdown delay; choose it to cover their termination time.
- Cleanup retains the `N` most recent matching archives by modification time and deletes older ones.
### `backup-k3s-control-plane-config.sh`
@@ -60,6 +62,7 @@ Optional:
- `SCALE_RETRY_COUNT` (default: `3`)
- `SCALE_RETRY_DELAY_SECONDS` (default: `5`)
- `SCALE_WAIT_SECONDS` (default: `30`): Fixed delay after scaling down and after restoring a mapped namespace.
- `ARGOCD_WAIT_TIMEOUT` (default: `300s`): Maximum wait for ArgoCD pods to disappear before processing folders.
- `LOG_LEVEL` (default: `info`)
- `TMP_STATE_DIR` (default: `/tmp/k8s-nfs-backup`): Parent directory for fresh per-run replica-state directories. A run never restores state files belonging to an earlier run.
- `NOTIFY_SUCCESS_URL` (default: `http://notify.haven/api/v2/notifications/backup`; set to empty to disable)