Files
base/deploy/backup-cronjob.yaml
Hera Zhao d19183923c
Some checks failed
Deploy Production / test (push) Failing after 1s
Deploy Production / deploy (push) Has been skipped
Test / unit-test (push) Failing after 1s
Test / e2e-test (push) Has been skipped
Test / build-check (push) Failing after 1s
Initial template: Vue 3 + FastAPI + SQLite full-stack with K8s deployment
Extracted from oil project — business logic removed, auth/db/deploy infrastructure
generalized with APP_NAME placeholders.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 22:13:06 +00:00

39 lines
1.2 KiB
YAML

apiVersion: batch/v1
kind: CronJob
metadata:
name: hourly-backup
namespace: APP_NAME
spec:
schedule: "0 * * * *"
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 2
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: registry.oci.euphon.net/APP_NAME:latest
command:
- sh
- -c
- |
BACKUP_DIR=/data/backups
mkdir -p $BACKUP_DIR
DATE=$(date +%Y%m%d_%H%M%S)
sqlite3 /data/app.db ".backup '$BACKUP_DIR/app_${DATE}.db'"
echo "Backup done: $BACKUP_DIR/app_${DATE}.db"
# Keep last 48 backups (2 days of hourly)
ls -t $BACKUP_DIR/app_*.db | tail -n +49 | xargs rm -f 2>/dev/null
echo "Backups retained: $(ls $BACKUP_DIR/app_*.db | wc -l)"
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: APP_NAME-data
restartPolicy: OnFailure
imagePullSecrets:
- name: regcred