From 86c4255d538bf4ddaf3766145e40ad517542d6c2 Mon Sep 17 00:00:00 2001 From: Mathis Date: Thu, 1 Feb 2024 16:25:19 +0000 Subject: [PATCH] Add pvc to restic cronjob --- apps/gitea/restic-backup.sh | 2 +- apps/gitea/restic-cronjob.yaml | 18 +++++++----------- apps/gitea/restic-pvc.yaml | 12 ++++++++++++ 3 files changed, 20 insertions(+), 12 deletions(-) create mode 100755 apps/gitea/restic-pvc.yaml diff --git a/apps/gitea/restic-backup.sh b/apps/gitea/restic-backup.sh index 391ea20..3ab960a 100644 --- a/apps/gitea/restic-backup.sh +++ b/apps/gitea/restic-backup.sh @@ -11,7 +11,7 @@ echo -e "\n${GREEN}`date` - Backing up Gitea...${NC}\n" gitea=$(kubectl get deploy -n gitea -l app=gitea -o name --no-headers=true) kubectl scale -n gitea --replicas=0 $gitea restic backup /gitea -restic backup /pg_backup/postgres_backup.dump +restic backup /backup/postgres_backup.dump kubectl scale -n gitea --replicas=1 $gitea # Forget and prune diff --git a/apps/gitea/restic-cronjob.yaml b/apps/gitea/restic-cronjob.yaml index b4fd49d..fb7b927 100644 --- a/apps/gitea/restic-cronjob.yaml +++ b/apps/gitea/restic-cronjob.yaml @@ -16,11 +16,9 @@ spec: - name: gitea-data persistentVolumeClaim: claimName: gitea-shared-storage - - name: postgres-data + - name: restic-backup-vol persistentVolumeClaim: - claimName: data-gitea-postgresql-0 - - name: postgres-backup-vol - emptyDir: {} + claimName: restic-backup-vol - name: backup-script-vol configMap: name: restic-backup-script @@ -29,7 +27,7 @@ spec: - name: postgres-dump-init image: bitnami/postgresql:15.3.0-debian-11-r24 command: ["/bin/sh", "-c"] - args: ["pg_dump -h gitea-postgresql -p 5432 -U gitea gitea -Fc > /pg_backup/postgres_backup.dump"] + args: ["pg_dump -h gitea-postgresql -p 5432 -U gitea gitea -Fc > /backup/postgres_backup.dump"] env: - name: PGPASSWORD valueFrom: @@ -37,10 +35,8 @@ spec: name: gitea-postgresql key: postgres-password volumeMounts: - - name: postgres-backup-vol - mountPath: /pg_backup - - name: postgres-data - mountPath: /bitnami/postgresql/data + - name: restic-backup-vol + mountPath: /backup containers: - name: restic-container @@ -51,8 +47,8 @@ spec: - secretRef: name: restic-secret volumeMounts: - - name: postgres-backup-vol - mountPath: /pg_backup + - name: restic-backup-vol + mountPath: /backup - name: gitea-data mountPath: /gitea - name: backup-script-vol diff --git a/apps/gitea/restic-pvc.yaml b/apps/gitea/restic-pvc.yaml new file mode 100755 index 0000000..da1b0de --- /dev/null +++ b/apps/gitea/restic-pvc.yaml @@ -0,0 +1,12 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: restic-backup-vol + namespace: gitea +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 5Gi + storageClassName: retain-local-path