This repository has been archived on 2026-02-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
breakpilot-pwa/scripts/daily-backup.sh
Benjamin Admin 21a844cb8a fix: Restore all files lost during destructive rebase
A previous `git pull --rebase origin main` dropped 177 local commits,
losing 3400+ files across admin-v2, backend, studio-v2, website,
klausur-service, and many other services. The partial restore attempt
(660295e2) only recovered some files.

This commit restores all missing files from pre-rebase ref 98933f5e
while preserving post-rebase additions (night-scheduler, night-mode UI,
NightModeWidget dashboard integration).

Restored features include:
- AI Module Sidebar (FAB), OCR Labeling, OCR Compare
- GPU Dashboard, RAG Pipeline, Magic Help
- Klausur-Korrektur (8 files), Abitur-Archiv (5+ files)
- Companion, Zeugnisse-Crawler, Screen Flow
- Full backend, studio-v2, website, klausur-service
- All compliance SDKs, agent-core, voice-service
- CI/CD configs, documentation, scripts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 09:51:32 +01:00

72 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# Tägliches Backup vom Mac Mini zum MacBook
# =============================================================================
# Dieses Script synchronisiert das Projekt vom Mac Mini zum MacBook
# um bei Festplattendefekt keine Daten zu verlieren.
#
# Installation:
# chmod +x ~/Projekte/breakpilot-pwa/scripts/daily-backup.sh
#
# Manuell ausführen:
# ~/Projekte/breakpilot-pwa/scripts/daily-backup.sh
#
# Automatisch täglich (via LaunchAgent - wird unten erstellt):
# Das Script läuft automatisch jeden Tag um 02:00 Uhr
# =============================================================================
set -e
# Konfiguration
MACMINI_HOST="benjaminadmin@macmini"
REMOTE_DIR="/Users/benjaminadmin/Projekte/breakpilot-pwa"
LOCAL_DIR="/Users/benjaminadmin/Projekte/breakpilot-pwa"
BACKUP_LOG="/Users/benjaminadmin/Projekte/backup-logs"
TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S)
# Log-Verzeichnis erstellen
mkdir -p "$BACKUP_LOG"
LOG_FILE="$BACKUP_LOG/backup-$TIMESTAMP.log"
echo "=== Backup gestartet: $TIMESTAMP ===" | tee "$LOG_FILE"
# 1. Prüfe Verbindung zum Mac Mini
echo "[1/4] Prüfe Verbindung zum Mac Mini..." | tee -a "$LOG_FILE"
if ! ping -c 1 -t 5 macmini &>/dev/null; then
echo "FEHLER: Mac Mini nicht erreichbar!" | tee -a "$LOG_FILE"
exit 1
fi
echo " ✓ Mac Mini erreichbar" | tee -a "$LOG_FILE"
# 2. Hole neuesten Stand vom Git Remote
echo "[2/4] Hole neueste Commits von Gitea..." | tee -a "$LOG_FILE"
cd "$LOCAL_DIR"
git fetch origin 2>&1 | tee -a "$LOG_FILE"
echo " ✓ Git fetch erfolgreich" | tee -a "$LOG_FILE"
# 3. Synchronisiere Docker-Volumes und Datenbanken (optional)
echo "[3/4] Sichere wichtige Daten vom Mac Mini..." | tee -a "$LOG_FILE"
# Postgres Backup
POSTGRES_BACKUP="$BACKUP_LOG/postgres-$TIMESTAMP.sql.gz"
ssh "$MACMINI_HOST" "/usr/local/bin/docker exec breakpilot-pwa-postgres pg_dump -U postgres breakpilot | gzip" > "$POSTGRES_BACKUP" 2>> "$LOG_FILE"
if [ -s "$POSTGRES_BACKUP" ]; then
echo " ✓ Postgres-Backup: $POSTGRES_BACKUP" | tee -a "$LOG_FILE"
else
echo " ⚠ Postgres-Backup fehlgeschlagen oder leer" | tee -a "$LOG_FILE"
fi
# 4. Aufräumen alter Backups (behalte letzte 7 Tage)
echo "[4/4] Räume alte Backups auf..." | tee -a "$LOG_FILE"
find "$BACKUP_LOG" -name "postgres-*.sql.gz" -mtime +7 -delete 2>/dev/null
find "$BACKUP_LOG" -name "backup-*.log" -mtime +7 -delete 2>/dev/null
echo " ✓ Alte Backups entfernt (>7 Tage)" | tee -a "$LOG_FILE"
echo "" | tee -a "$LOG_FILE"
echo "=== Backup abgeschlossen: $(date +%Y-%m-%d_%H-%M-%S) ===" | tee -a "$LOG_FILE"
echo "" | tee -a "$LOG_FILE"
echo "Zusammenfassung:" | tee -a "$LOG_FILE"
echo " - Git Repository: Aktuell (via fetch)" | tee -a "$LOG_FILE"
echo " - Postgres-Backup: $POSTGRES_BACKUP" | tee -a "$LOG_FILE"
echo " - Log: $LOG_FILE" | tee -a "$LOG_FILE"