Add vaultwarden backup strategy

This commit is contained in:
Tanguy Herbron 2022-09-10 03:44:23 +02:00
parent 741721b389
commit 38da63153d
4 changed files with 43 additions and 0 deletions

25
vaultwarden/cronjob.yaml Normal file
View File

@ -0,0 +1,25 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup-job
namespace: vaultwarden
spec:
schedule: "0 4 * * *" # Every day at 4AM
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
containers:
- name: maria-backup
image: mariadb
command: ["sh", "-c", "/usr/bin/mysqldump -h vaultwarden-svc.vaultwarden.svc.cluster.local -u root -pexample vaultwarden > /backup/vaultwarden/backup-$(date +'%H_%M-%d_%m_%Y').sql"]
volumeMounts:
- name: vaultwarden-backup
mountPath: /backup/vaultwarden
subPath: vaultwarden
volumes:
- name: vaultwarden-backup
persistentVolumeClaim:
claimName: vaultwarden-backup-pvc
restartPolicy: OnFailure

View File

@ -13,6 +13,8 @@ spec:
labels:
app: vaultwarden
spec:
hostname: vaultwarden
subdomain: vaultwarden
containers:
- name: vaultwarden
image: vaultwarden/server

12
vaultwarden/pvc.yaml Normal file
View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: vaultwarden-backup-pvc
namespace: vaultwarden
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: flat-storage-class

View File

@ -9,5 +9,9 @@ spec:
port: 80
protocol: TCP
targetPort: 80
- name: db
port: 3306
protocol: TCP
targetPort: 3306
selector:
app: vaultwarden