diff --git a/home-assistant/Chart.yaml b/home-assistant/Chart.yaml index a1262ff..e0a3e06 100644 --- a/home-assistant/Chart.yaml +++ b/home-assistant/Chart.yaml @@ -5,5 +5,5 @@ type: application annotations: version-source: github-release:home-assistant/core version-pattern: "s|^v||" -version: 0.1.17 +version: 0.1.18 appVersion: "2026.4.1" diff --git a/home-assistant/templates/pvc-backup-cronjob.yaml b/home-assistant/templates/pvc-backup-cronjob.yaml new file mode 100644 index 0000000..ed3f17a --- /dev/null +++ b/home-assistant/templates/pvc-backup-cronjob.yaml @@ -0,0 +1,71 @@ +{{- if .Values.pvcBackup.enabled -}} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "home-assistant.fullname" . }}-pvc-backup + {{- if .Values.namespaceOverride }} + namespace: {{ .Values.namespaceOverride }} + {{- end }} + labels: + {{- include "home-assistant.labels" . | nindent 4 }} +spec: + schedule: {{ .Values.pvcBackup.schedule | quote }} + jobTemplate: + spec: + template: + spec: + containers: + - name: pvc-backup + image: {{ .Values.pvcBackup.image }} + command: + - /bin/sh + - -c + - | + set -e + BACKUP_DIR="/backup/{{ include "home-assistant.fullname" . }}" + TIMESTAMP=$(date +%Y%m%d-%H%M%S) + mkdir -p "$BACKUP_DIR" + # Create compressed tar of config PVC + tar czf "$BACKUP_DIR/config-${TIMESTAMP}.tar.gz" -C /config . + # Retention: Delete backups older than specified days + find "$BACKUP_DIR" -name "config-*.tar.gz" -mtime +{{ .Values.pvcBackup.retentionDays }} -delete + volumeMounts: + - name: config + mountPath: /config + readOnly: true + - name: backup-storage + mountPath: /backup + volumes: + - name: config + persistentVolumeClaim: + claimName: {{ .Values.persistence.config.existingClaim | default (include "home-assistant.fullname" .) }} + - name: backup-storage + hostPath: + path: {{ .Values.pvcBackup.storagePath }} + type: DirectoryOrCreate + restartPolicy: OnFailure + {{- if .Values.pvcBackup.node }} + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - {{ .Values.pvcBackup.node }} + {{- else }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 10 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 10 }} + {{- end }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 10 }} + {{- end }} +{{- end }} diff --git a/home-assistant/values.yaml b/home-assistant/values.yaml index 33694b9..f220f7a 100644 --- a/home-assistant/values.yaml +++ b/home-assistant/values.yaml @@ -130,6 +130,15 @@ backup: existingSecret: "" secretKey: password +pvcBackup: + enabled: false + schedule: "0 3 * * *" + image: busybox:latest + retentionDays: 7 + storagePath: /storage/backups/pvc + # Node to run backup on (hostname). Overrides global affinity/tolerations. + node: "" + nodeSelector: {} tolerations: []