Backup und restore für die DB dazu gebaut

This commit is contained in:
2026-05-02 22:06:07 +02:00
parent fc35e9b6e7
commit cc663487e0
3 changed files with 124 additions and 0 deletions
Executable
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
# backup-db.sh
set -euo pipefail
source /Users/rxf/Projekte/wetterstation/.env
BACKUP_DIR="/Users/rxf/Projekte/wetterstation/backups"
mkdir -p "$BACKUP_DIR"
FILENAME="wetterstation_$(date +%Y%m%d_%H%M).dump"
docker exec wetterstation_db pg_dump -U "$DB_USER" -d "$DB_NAME" -F c -f /tmp/backup.dump
docker cp wetterstation_db:/tmp/backup.dump "$BACKUP_DIR/$FILENAME"
docker exec wetterstation_db rm /tmp/backup.dump
# Alte Backups löschen (älter als 30 Tage)
find "$BACKUP_DIR" -name "*.dump" -mtime +30 -delete
echo "Backup gespeichert: $BACKUP_DIR/$FILENAME"