fix: report scheduled backup failures
This commit is contained in:
@@ -23,7 +23,8 @@ jobs:
|
|||||||
- run: python -m pip install -r requirements.txt
|
- run: python -m pip install -r requirements.txt
|
||||||
- run: python -m pytest -q
|
- run: python -m pytest -q
|
||||||
- run: node --check app/static/admin.js
|
- run: node --check app/static/admin.js
|
||||||
- run: sh -n infra/postgres-backup.sh infra/install-postgres-backup-cron.sh
|
- run: sh -n infra/postgres-backup.sh
|
||||||
|
- run: sh -n infra/install-postgres-backup-cron.sh
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
|
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 0.8.13
|
## 0.8.14
|
||||||
|
|
||||||
- Production CD больше не создаёт backup при каждом deploy; еженедельная задача
|
- Production CD больше не создаёт backup при каждом deploy; еженедельная задача
|
||||||
сохраняет один полный PostgreSQL backup с атомарной заменой.
|
сохраняет один полный PostgreSQL backup с атомарной заменой; ошибки и
|
||||||
|
пропущенные из-за lock запуски пишутся в system log.
|
||||||
|
|
||||||
## 0.8.12
|
## 0.8.12
|
||||||
|
|
||||||
|
|||||||
@@ -135,4 +135,4 @@ node --check app/static/admin.js
|
|||||||
|
|
||||||
Тесты с данными используют временную SQLite; отдельные API smoke-тесты запускают приложение с его текущей конфигурацией. Браузерная проверка: `pip install playwright`, `python -m playwright install chromium`, затем `python tests/browser_admin.py`. Она проверяет реальный рендеринг страниц, клавиатуру, диалог, фильтры и восстановление прогресса после ошибки. Скриншоты сохраняются во временную папку; путь выводится в конце.
|
Тесты с данными используют временную SQLite; отдельные API smoke-тесты запускают приложение с его текущей конфигурацией. Браузерная проверка: `pip install playwright`, `python -m playwright install chromium`, затем `python tests/browser_admin.py`. Она проверяет реальный рендеринг страниц, клавиатуру, диалог, фильтры и восстановление прогресса после ошибки. Скриншоты сохраняются во временную папку; путь выводится в конце.
|
||||||
|
|
||||||
Версия сервиса: `0.8.13`. Админка всегда показывает версии backend и frontend в footer.
|
Версия сервиса: `0.8.14`. Админка всегда показывает версии backend и frontend в footer.
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
APP_VERSION = "0.8.13"
|
APP_VERSION = "0.8.14"
|
||||||
FRONTEND_VERSION = "0.8.13"
|
FRONTEND_VERSION = "0.8.14"
|
||||||
BACKEND_VERSION = "0.8.13"
|
BACKEND_VERSION = "0.8.14"
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ app_dir=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
|||||||
trap 'rm -f -- "$temporary"' EXIT HUP INT TERM
|
trap 'rm -f -- "$temporary"' EXIT HUP INT TERM
|
||||||
|
|
||||||
crontab -l 2>/dev/null | grep -v 'postgres-backup.sh' > "$temporary" || true
|
crontab -l 2>/dev/null | grep -v 'postgres-backup.sh' > "$temporary" || true
|
||||||
printf '%s\n' "30 3 * * 0 flock -n /tmp/miem-postgres-backup.lock $app_dir/infra/postgres-backup.sh >/dev/null 2>&1" >> "$temporary"
|
printf '%s\n' "30 3 * * 0 flock -w 3600 /tmp/miem-postgres-backup.lock $app_dir/infra/postgres-backup.sh || logger -t miem-postgres-backup -- 'backup skipped or failed'" >> "$temporary"
|
||||||
crontab "$temporary"
|
crontab "$temporary"
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ backup_dir="$HOME/backups/postgres"
|
|||||||
backup="$backup_dir/postgres-latest.sql"
|
backup="$backup_dir/postgres-latest.sql"
|
||||||
temporary="$backup.tmp.$$"
|
temporary="$backup.tmp.$$"
|
||||||
|
|
||||||
|
log() { logger -t miem-postgres-backup -- "$*" 2>/dev/null || true; }
|
||||||
|
|
||||||
mkdir -p "$backup_dir"
|
mkdir -p "$backup_dir"
|
||||||
trap 'rm -f -- "$temporary"' EXIT HUP INT TERM
|
trap 'status=$?; rm -f -- "$temporary"; [ "$status" -eq 0 ] || log "backup failed"; exit "$status"' EXIT HUP INT TERM
|
||||||
cd "$app_dir"
|
cd "$app_dir"
|
||||||
|
|
||||||
docker compose exec -T postgres sh -c 'pg_dumpall -U "$POSTGRES_USER"' > "$temporary"
|
docker compose exec -T postgres sh -c 'pg_dumpall -U "$POSTGRES_USER"' > "$temporary"
|
||||||
test -s "$temporary"
|
test -s "$temporary"
|
||||||
mv "$temporary" "$backup"
|
mv "$temporary" "$backup"
|
||||||
find "$HOME/backups/miem_workers" -maxdepth 1 -type f -name 'miem_workers-*.sql' -delete 2>/dev/null || true
|
find "$HOME/backups/miem_workers" -maxdepth 1 -type f -name 'miem_workers-*.sql' -delete 2>/dev/null || true
|
||||||
printf '%s\n' "Created $backup"
|
log "created $backup"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "miem-workers"
|
name = "miem-workers"
|
||||||
version = "0.8.13"
|
version = "0.8.14"
|
||||||
description = "MIEM employees parser, admin API, and web admin"
|
description = "MIEM employees parser, admin API, and web admin"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def test_health_returns_versions():
|
|||||||
response = TestClient(app).get("/api/health")
|
response = TestClient(app).get("/api/health")
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.json()["backend_version"] == "0.8.13"
|
assert response.json()["backend_version"] == "0.8.14"
|
||||||
|
|
||||||
|
|
||||||
def test_api_employees_and_stats_require_admin_session():
|
def test_api_employees_and_stats_require_admin_session():
|
||||||
|
|||||||
Reference in New Issue
Block a user