- Added a new query parameter `collapseDuplicateSessions` to the activity listing endpoint to enable deduplication of sessions based on date, type, start time, duration, and calories. - Enhanced backend logic to handle deduplication and return the most recent entry for duplicate sessions. - Updated frontend to support the new deduplication feature, improving the clarity of displayed activity data. - Modified API utility to include the new parameter in requests for activity data.
36 lines
1.4 KiB
Bash
36 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
# Volles PostgreSQL-Backup im Custom-Format (pg_restore-kompatibel).
|
|
# Auf dem Host ausführen, wo der Postgres-Container läuft (z. B. Raspberry Pi mit docker compose).
|
|
#
|
|
# BACKUP_DIR=/path/to/safe/storage ./scripts/backup/mitai_pg_dump.sh
|
|
#
|
|
# Variablen (optional): POSTGRES_CONTAINER, POSTGRES_DB, POSTGRES_USER, BACKUP_DIR
|
|
|
|
set -euo pipefail
|
|
|
|
CONTAINER="${POSTGRES_CONTAINER:-mitai-db-prod}"
|
|
DB="${POSTGRES_DB:-mitai_prod}"
|
|
USER="${POSTGRES_USER:-mitai_prod}"
|
|
OUT_DIR="${BACKUP_DIR:-.}"
|
|
STAMP="$(date +%Y%m%d_%H%M%S)"
|
|
mkdir -p "${OUT_DIR}"
|
|
OUT="${OUT_DIR}/${DB}_${STAMP}.dump"
|
|
|
|
if ! docker inspect "$CONTAINER" &>/dev/null; then
|
|
echo "Container nicht gefunden: $CONTAINER" >&2
|
|
exit 1
|
|
fi
|
|
|
|
docker exec "$CONTAINER" pg_dump -U "$USER" -Fc --no-owner --no-acl "$DB" > "$OUT"
|
|
ls -la "$OUT"
|
|
echo "OK: $OUT (zum Zurückspielen: siehe Kommentar unten in diesem Skript)"
|
|
|
|
# ── Restore (nur bei Notfall; Backend vorher stoppen, sonst offene Verbindungen) ──
|
|
# docker compose stop backend
|
|
# docker cp "$OUT" "$CONTAINER:/tmp/restore.dump"
|
|
# docker exec "$CONTAINER" pg_restore -U "$USER" -d "$DB" --clean --if-exists --no-owner --no-acl /tmp/restore.dump
|
|
# docker compose start backend
|
|
#
|
|
# Hinweis: --clean entfernt Objekte vor dem Wiederherstellen; kurze Unterbrechung der DB.
|
|
# Für „nur lesen“ Backup reicht die .dump-Datei auf externem Medium zu kopieren.
|