Some checks are pending
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>
39 lines
1.2 KiB
YAML
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
|