BACKUP TOOLS - Datensicherung und Wiederherstellung
===================================================

Stand: 2026-01-23
Pfad: docs/help/tools/backup.txt

BESCHREIBUNG
------------
Tools zur Datensicherung und Wiederherstellung von BACH-Daten:
  - Lokale Backups erstellen und verwalten
  - NAS-Backups (wenn verfügbar)
  - Template-Restore (Originaldateien zurücksetzen)
  - Distribution-Pakete erstellen

HAUPT-TOOL: backup_manager.py
=============================
Zentrales Tool für alle Backup-Operationen.
Kann direkt oder über CLI aufgerufen werden.

GRUNDBEFEHLE:

  # Backup erstellen
  bach backup create                  Lokales Backup
  bach backup create --to-nas         Mit NAS-Kopie

  # Backups anzeigen
  bach backup list                    Lokale Backups
  bach backup list --nas              NAS-Backups anzeigen
  bach backup info <n>                Backup-Details

  # Wiederherstellen
  bach restore backup <n>             Bestimmtes Backup
  bach restore backup latest          Neuestes Backup
  bach restore backup latest --force  Ohne Bestaetigung

  # Template zurücksetzen
  bach restore template SKILL.md      Auf Original

DIST_TYPE KONZEPT
=================
Das Backup-System basiert auf Distribution-Typen:

  dist_type = 2 (CORE)
    -> Distribution IST das Backup
    -> bach.py, hub/, tools/, skills/, docs/help/
    -> NICHT separat gesichert

  dist_type = 1 (TEMPLATE)
    -> 1x Snapshot bei Installation
    -> bach restore template <datei>

  dist_type = 0 (USER_DATA)
    -> Normale Backup-Rotation
    -> Tasks, Memory, Logs, Inbox

WAS WIRD GESICHERT?
-------------------
USER_DATA (dist_type = 0):
  tasks          Alle Tasks, Status, History
  memory/        Sessions, Longterm, Archive
  logs/          Session-Logs
  user/inbox/    Nachrichten, Agenda

NICHT gesichert (CORE/TEMPLATE):
  bach.py, schema.sql, hub/
  tools/, skills/, docs/help/
  (sind Teil der Distribution)

BACKUP-ROTATION
===============
Automatische Rotation verhindert Speicherüberlauf:

  Lokal (data/_backups/):            7 Backups behalten
  NAS:                  30 Backups behalten
  OneDrive:             Automatisch (Versionsverlauf)

SPEICHERORTE
============
  Lokal:    BACH/system/data/_backups/
  NAS:      \\NAS-HOST\fritz.nas\Extreme_SSD\BACKUP\BACH_Backups
  Dist:     BACH/distributions/

HINWEIS:
  NAS nur im Heimnetzwerk erreichbar!
  Bei Abwesenheit --to-nas nicht verwenden.

DIREKTE TOOL-NUTZUNG
====================
backup_manager.py kann auch direkt aufgerufen werden:

  python tools/backup_manager.py create [--to-nas]
  python tools/backup_manager.py list [--nas]
  python tools/backup_manager.py restore backup <n>
  python tools/backup_manager.py restore template <file>

SNAPSHOTS (Session-basiert)
===========================
Für Session-Snapshots siehe Memory-System:

  bach snapshot create           Manueller Snapshot
  bach snapshot load             Letzten Snapshot laden
  bach snapshot list             Snapshots anzeigen

  -> Automatisch bei Shutdown (bei >= 3 Änderungen)
  -> Gespeichert in session_snapshots Tabelle

DISTRIBUTION-BEFEHLE
====================
Pakete für Verteilung erstellen:

  bach dist create base       Basis-Paket erstellen
  bach dist list                 Pakete anzeigen
  bach dist status               Verteilungsstatus
  bach dist verify               Integrität prüfen

TYPISCHE ANWENDUNGSFAELLE
=========================

1. VOR GRÖSSEREN ÄNDERUNGEN
   Sicherheits-Backup erstellen:
   bach backup create

2. TAEGLICH (HEIMNETZWERK)
   Backup mit NAS-Kopie:
   bach backup create --to-nas

3. NACH ABSTURZ/FEHLER
   Letzte funktionierende Version:
   bach restore backup latest

4. SKILL.MD ZURÜCKSETZEN
   Bei kaputten Änderungen:
   bach restore template SKILL.md

5. PAKET FÜR ANDEREN RECHNER
   Distribution erstellen:
   bach dist create base

6. SESSION FORTSETZEN
   Nach Neustart/Chat-Wechsel:
   bach snapshot load

VERWANDTE SKILLS
================
  skills/_services/builder.md   CREATE, EXPORT, DISTRIBUTE, BACKUP
  docs/BACKUP_SYSTEM.md         Urspruengliches Konzept

SIEHE AUCH
----------
  bach --help backup             Vollständige Backup-Hilfe
  bach --help dist               Distribution-Befehle
  bach --help memory             Memory/Snapshot-System
  bach --help tools              Tool-Übersicht
