Compare commits

...

2 Commits

Author SHA1 Message Date
bf29551a31 ci: retrigger after Batch 2 timeout flake
All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 6s
PR Preview / teardown-preview (pull_request) Successful in 13s
PR Preview / deploy-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
Deploy Production / deploy (push) Successful in 5s
Test / e2e-test (push) Successful in 2m59s
2026-04-15 10:05:21 +00:00
a8c9c2252f fix: hourly-backup 改用 python sqlite3 API 做一致性备份
Some checks failed
Test / unit-test (push) Successful in 5s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / build-check (push) Successful in 4s
Test / e2e-test (push) Failing after 6m1s
PR Preview / test (pull_request) Successful in 6s
PR Preview / deploy-preview (pull_request) Successful in 8s
镜像里没有 sqlite3 CLI,原来的 .backup 命令 15 天前就静默失败了。
daily-minio-backup 用 cp 就够,但 hourly 每小时跑要求更强一致性,
改用 Python 内置 sqlite3 的 .backup() API。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 09:56:40 +00:00

View File

@@ -18,12 +18,14 @@ spec:
- sh
- -c
- |
set -e
BACKUP_DIR=/data/backups
mkdir -p $BACKUP_DIR
DATE=$(date +%Y%m%d_%H%M%S)
# Backup SQLite database using .backup for consistency
sqlite3 /data/oil_calculator.db ".backup '$BACKUP_DIR/oil_calculator_${DATE}.db'"
echo "Backup done: $BACKUP_DIR/oil_calculator_${DATE}.db ($(du -h $BACKUP_DIR/oil_calculator_${DATE}.db | cut -f1))"
DST="$BACKUP_DIR/oil_calculator_${DATE}.db"
# Consistent snapshot via Python's sqlite3 .backup API (sqlite3 CLI not in image)
python3 -c "import sqlite3; s=sqlite3.connect('/data/oil_calculator.db'); d=sqlite3.connect('$DST'); s.backup(d); d.close(); s.close()"
echo "Backup done: $DST ($(du -h $DST | cut -f1))"
# Keep last 48 backups (2 days of hourly)
ls -t $BACKUP_DIR/oil_calculator_*.db | tail -n +49 | xargs rm -f 2>/dev/null
echo "Backups retained: $(ls $BACKUP_DIR/oil_calculator_*.db | wc -l)"