Files
schedule-planner/deploy/backup-cronjob.yaml
Hera Zhao d3f3b4f37b
Some checks failed
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 3s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / e2e-test (push) Failing after 55s
PR Preview / deploy-preview (pull_request) Failing after 40s
Refactor to Vue 3 + FastAPI + SQLite architecture
- Backend: FastAPI + SQLite (WAL mode), 22 tables, ~40 API endpoints
- Frontend: Vue 3 + Vite + Pinia + Vue Router, 8 views, 3 stores
- Database: migrate from JSON file to SQLite with proper schema
- Dockerfile: multi-stage build (node + python)
- Deploy: K8s manifests (namespace, deployment, service, ingress, pvc, backup)
- CI/CD: Gitea Actions (test, deploy, PR preview at pr-$id.planner.oci.euphon.net)
- Tests: 20 Cypress E2E test files, 196 test cases, ~85% coverage
- Doc: test-coverage.md with full feature coverage report

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

51 lines
1.7 KiB
YAML

apiVersion: batch/v1
kind: CronJob
metadata:
name: planner-backup-minio
namespace: planner
spec:
schedule: "0 */6 * * *"
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 3
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: python:3.12-alpine
command:
- /bin/sh
- -c
- |
apk add --no-cache curl sqlite >/dev/null 2>&1
curl -sL https://dl.min.io/client/mc/release/linux-arm64/mc -o /usr/local/bin/mc
chmod +x /usr/local/bin/mc
mc alias set s3 http://minio.minio.svc:9000 admin HpYMIVH0WN79VkzF4L4z8Zx1
TS=$(date +%Y%m%d_%H%M%S)
# SQLite safe backup
sqlite3 /data/planner.db ".backup /tmp/planner_${TS}.db"
mc cp "/tmp/planner_${TS}.db" "s3/planner-backups/planner_${TS}.db"
# Keep only last 60 backups
mc ls s3/planner-backups/ --json | python3 -c "
import sys, json
files = []
for line in sys.stdin:
d = json.loads(line)
if d.get('key','').startswith('planner_'):
files.append(d['key'])
files.sort()
for f in files[:-60]:
print(f)
" | while read f; do mc rm "s3/planner-backups/$f"; done
echo "Backup done: ${TS}"
volumeMounts:
- name: data
mountPath: /data
readOnly: true
volumes:
- name: data
persistentVolumeClaim:
claimName: planner-data
restartPolicy: OnFailure