Add pvc to restic cronjob

This commit is contained in:
Mathis 2024-02-01 16:25:19 +00:00
parent f37f961a10
commit 86c4255d53
3 changed files with 20 additions and 12 deletions

View File

@ -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) gitea=$(kubectl get deploy -n gitea -l app=gitea -o name --no-headers=true)
kubectl scale -n gitea --replicas=0 $gitea kubectl scale -n gitea --replicas=0 $gitea
restic backup /gitea restic backup /gitea
restic backup /pg_backup/postgres_backup.dump restic backup /backup/postgres_backup.dump
kubectl scale -n gitea --replicas=1 $gitea kubectl scale -n gitea --replicas=1 $gitea
# Forget and prune # Forget and prune

View File

@ -16,11 +16,9 @@ spec:
- name: gitea-data - name: gitea-data
persistentVolumeClaim: persistentVolumeClaim:
claimName: gitea-shared-storage claimName: gitea-shared-storage
- name: postgres-data - name: restic-backup-vol
persistentVolumeClaim: persistentVolumeClaim:
claimName: data-gitea-postgresql-0 claimName: restic-backup-vol
- name: postgres-backup-vol
emptyDir: {}
- name: backup-script-vol - name: backup-script-vol
configMap: configMap:
name: restic-backup-script name: restic-backup-script
@ -29,7 +27,7 @@ spec:
- name: postgres-dump-init - name: postgres-dump-init
image: bitnami/postgresql:15.3.0-debian-11-r24 image: bitnami/postgresql:15.3.0-debian-11-r24
command: ["/bin/sh", "-c"] 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: env:
- name: PGPASSWORD - name: PGPASSWORD
valueFrom: valueFrom:
@ -37,10 +35,8 @@ spec:
name: gitea-postgresql name: gitea-postgresql
key: postgres-password key: postgres-password
volumeMounts: volumeMounts:
- name: postgres-backup-vol - name: restic-backup-vol
mountPath: /pg_backup mountPath: /backup
- name: postgres-data
mountPath: /bitnami/postgresql/data
containers: containers:
- name: restic-container - name: restic-container
@ -51,8 +47,8 @@ spec:
- secretRef: - secretRef:
name: restic-secret name: restic-secret
volumeMounts: volumeMounts:
- name: postgres-backup-vol - name: restic-backup-vol
mountPath: /pg_backup mountPath: /backup
- name: gitea-data - name: gitea-data
mountPath: /gitea mountPath: /gitea
- name: backup-script-vol - name: backup-script-vol

12
apps/gitea/restic-pvc.yaml Executable file
View File

@ -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