Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions torchlite-mongdb-backup/dev/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: mongodb-backup
spec:
schedule: "*/5 * * * *" # Runs backup every 5 minutes for testing purposes
jobTemplate:
spec:
template:
spec:
containers:
- name: mongodump
image: quay.io/mongodb/mongodb-community-server:6.0.5-ubi8
command:
- sh
- -c
- |
# Perform backup
mongodump --host=mongodb-svc -u $username -p $password --port=27017 --out=/backup/$(date +\%Y-\%m-\%dT\%H-\%M-\%S)
# Remove backups older than 2 months
find /backup -type d -mtime +30 -exec rm -rf {} +
envFrom:
- secretRef:
name: mongodb-admin-torchlite
volumeMounts:
- name: backup-storage
mountPath: /backup
restartPolicy: OnFailure
volumes:
- name: backup-storage
persistentVolumeClaim:
claimName: mongodb-backup-pvc
12 changes: 12 additions & 0 deletions torchlite-mongdb-backup/dev/pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: mongodb-backup-pv
spec:
capacity:
storage: 100Gi # 2 times the size of the dev mongodb persistent volume as we will be retaining the most recent 2 backups in the backup volume
accessModes:
- ReadWriteOnce
hostPath:
path: /mnt/mongodb-backup
type: DirectoryOrCreate
10 changes: 10 additions & 0 deletions torchlite-mongdb-backup/dev/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongodb-backup-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
28 changes: 28 additions & 0 deletions torchlite-mongodb-backup-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: torchlite-mongodb-backup-app
namespace: argocd
labels:
env: dev
annotations:
notifications.argoproj.io/subscribe.on-deployed.slack: torchlite
notifications.argoproj.io/subscribe.on-health-degraded.slack: torchlite
spec:
project: default

source:
repoURL: https://github.com/htrc/torchlite-argocd.git
targetRevision: main
path: torchlite-mongodb-backup/dev
destination:
server: https://kubernetes.default.svc
namespace: torchlite-dev

syncPolicy:
syncOptions:
- CreateNamespace=true

automated:
selfHeal: true
prune: true