Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c8a11d82d | |||
| ae7a2ff9c7 | |||
| 8414194867 | |||
| 342264d178 | |||
| 1cfb947ae6 | |||
| 43976cb1a1 |
@@ -0,0 +1,25 @@
|
||||
apiVersion: longhorn.io/v1beta2
|
||||
kind: RecurringJob
|
||||
metadata:
|
||||
name: daily-snapshot
|
||||
namespace: longhorn-system
|
||||
spec:
|
||||
cron: "0 1 * * *"
|
||||
task: snapshot
|
||||
retain: 7
|
||||
concurrency: 2
|
||||
labels:
|
||||
backup-tier: daily
|
||||
---
|
||||
apiVersion: longhorn.io/v1beta2
|
||||
kind: RecurringJob
|
||||
metadata:
|
||||
name: weekly-backup
|
||||
namespace: longhorn-system
|
||||
spec:
|
||||
cron: "0 3 * * 0"
|
||||
task: backup
|
||||
retain: 4
|
||||
concurrency: 1
|
||||
labels:
|
||||
backup-tier: weekly
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: backups
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: argocd
|
||||
@@ -0,0 +1,59 @@
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: pelican-pg-backup
|
||||
namespace: backups
|
||||
spec:
|
||||
schedule: "0 2 * * *"
|
||||
concurrencyPolicy: Forbid
|
||||
successfulJobsHistoryLimit: 3
|
||||
failedJobsHistoryLimit: 3
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: pg-dump
|
||||
image: postgres:16-alpine
|
||||
env:
|
||||
- name: PGPASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pelican-pg-backup-credentials
|
||||
key: password
|
||||
- name: PGHOST
|
||||
value: postgresql.pelican.svc.cluster.local
|
||||
- name: PGUSER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pelican-pg-backup-credentials
|
||||
key: username
|
||||
- name: PGDATABASE
|
||||
value: pelican
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
set -e
|
||||
BACKUP_DIR=/backups/pelican
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
FILENAME="$BACKUP_DIR/pelican-$(date +%Y%m%d-%H%M%S).sql.gz"
|
||||
pg_dump -h "$PGHOST" -U "$PGUSER" -d "$PGDATABASE" | gzip > "$FILENAME"
|
||||
echo "Backup written: $FILENAME"
|
||||
find "$BACKUP_DIR" -name '*.sql.gz' -mtime +7 -delete
|
||||
echo "Retention cleanup done (keeping 7 days)"
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
volumeMounts:
|
||||
- name: backup-storage
|
||||
mountPath: /backups
|
||||
volumes:
|
||||
- name: backup-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: backup-storage
|
||||
@@ -0,0 +1,22 @@
|
||||
apiVersion: external-secrets.io/v1beta1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: pelican-pg-backup-credentials
|
||||
namespace: backups
|
||||
spec:
|
||||
refreshInterval: 1h
|
||||
secretStoreRef:
|
||||
name: vault-backend
|
||||
kind: ClusterSecretStore
|
||||
target:
|
||||
name: pelican-pg-backup-credentials
|
||||
creationPolicy: Owner
|
||||
data:
|
||||
- secretKey: username
|
||||
remoteRef:
|
||||
key: Talos Cluster/pelican/panel/db
|
||||
property: DB_USER
|
||||
- secretKey: password
|
||||
remoteRef:
|
||||
key: Talos Cluster/pelican/panel/db
|
||||
property: DB_PASSWORD
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: backup-storage
|
||||
namespace: backups
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: longhorn
|
||||
resources:
|
||||
requests:
|
||||
storage: 50Gi
|
||||
Reference in New Issue
Block a user