From 57d59933e1c5090927832e31284cac27760156ad Mon Sep 17 00:00:00 2001
From: Angelo Fausti <angelofausti@gmail.com>
Date: Mon, 6 Jan 2025 10:58:10 -0700
Subject: [PATCH] Add backup retention

- retention_days parameter is optional, it doesn't apply to incremental backups for example.
- The order we write the entries in the backup items list is preserved, so backups that take less time can be executed first.
---
 applications/sasquatch/README.md                 | 2 +-
 applications/sasquatch/charts/backup/README.md   | 2 +-
 applications/sasquatch/charts/backup/values.yaml | 6 ++++--
 applications/sasquatch/values-idfdev.yaml        | 6 ++++--
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/applications/sasquatch/README.md b/applications/sasquatch/README.md
index fbc7bcd80b..08492896ca 100644
--- a/applications/sasquatch/README.md
+++ b/applications/sasquatch/README.md
@@ -108,7 +108,7 @@ Rubin Observatory's telemetry service
 | app-metrics.resources | object | See `values.yaml` | Kubernetes resources requests and limits |
 | app-metrics.tolerations | list | `[]` | Tolerations for pod assignment |
 | backup.affinity | object | `{}` | Affinity rules for the backups deployment pod |
-| backup.backupItems | list | `[{"enabled":false,"name":"influxdb-enterprise"},{"enabled":false,"name":"chronograf"},{"enabled":false,"name":"kapacitor"}]` | List of items to backup, must match the names in the sasquatch backup script |
+| backup.backupItems | list | `[{"enabled":false,"name":"chronograf","retention_days":7},{"enabled":false,"name":"kapacitor","retention_days":7},{"enabled":false,"name":"influxdb-enterprise-incremental"}]` | List of items to backup, must match the names in the sasquatch backup script |
 | backup.image.pullPolicy | string | `"IfNotPresent"` | Pull policy for the backups image |
 | backup.image.repository | string | `"ghcr.io/lsst-sqre/sasquatch"` | Image to use in the backups deployment |
 | backup.image.tag | string | The appVersion of the chart | Tag of image to use |
diff --git a/applications/sasquatch/charts/backup/README.md b/applications/sasquatch/charts/backup/README.md
index 8ac325ce1c..7aafeaa31e 100644
--- a/applications/sasquatch/charts/backup/README.md
+++ b/applications/sasquatch/charts/backup/README.md
@@ -7,7 +7,7 @@ Backup Sasquatch data
 | Key | Type | Default | Description |
 |-----|------|---------|-------------|
 | affinity | object | `{}` | Affinity rules for the backups deployment pod |
-| backupItems | list | `[{"enabled":false,"name":"influxdb-enterprise"},{"enabled":false,"name":"chronograf"},{"enabled":false,"name":"kapacitor"}]` | List of items to backup, must match the names in the sasquatch backup script |
+| backupItems | list | `[{"enabled":false,"name":"chronograf","retention_days":7},{"enabled":false,"name":"kapacitor","retention_days":7},{"enabled":false,"name":"influxdb-enterprise-incremental"}]` | List of items to backup, must match the names in the sasquatch backup script |
 | image.pullPolicy | string | `"IfNotPresent"` | Pull policy for the backups image |
 | image.repository | string | `"ghcr.io/lsst-sqre/sasquatch"` | Image to use in the backups deployment |
 | image.tag | string | The appVersion of the chart | Tag of image to use |
diff --git a/applications/sasquatch/charts/backup/values.yaml b/applications/sasquatch/charts/backup/values.yaml
index a63bd4f6d2..b9da747cc1 100644
--- a/applications/sasquatch/charts/backup/values.yaml
+++ b/applications/sasquatch/charts/backup/values.yaml
@@ -26,12 +26,14 @@ persistence:
 
 # -- List of items to backup, must match the names in the sasquatch backup script
 backupItems:
-  - name: "influxdb-enterprise"
-    enabled: false
   - name: "chronograf"
     enabled: false
+    retention_days: 7
   - name: "kapacitor"
     enabled: false
+    retention_days: 7
+  - name: "influxdb-enterprise-incremental"
+    enabled: false
 
 # -- Affinity rules for the backups deployment pod
 affinity: {}
diff --git a/applications/sasquatch/values-idfdev.yaml b/applications/sasquatch/values-idfdev.yaml
index 30de5bc742..77514f7f99 100644
--- a/applications/sasquatch/values-idfdev.yaml
+++ b/applications/sasquatch/values-idfdev.yaml
@@ -170,9 +170,11 @@ backup:
     size: 500Gi
     storageClass: standard
   backupItems:
-    - name: "influxdb-enterprise"
-      enabled: true
     - name: "chronograf"
       enabled: true
+      retention_days: 3
     - name: "kapacitor"
       enabled: true
+      retention_days: 3
+    - name: "influxdb-enterprise-incremental"
+      enabled: true