Problem: Backups wurden ohne Root-Rechte erstellt. Dadurch wurden Datei- berechtigungen (UID/GID, rwx, ACLs, xattrs) nicht korrekt uebernommen. Root-Dateien konnten nicht gelesen werden. Backups waren unvollstaendig. Loesung: - rsync_manager: create_snapshot() nutzt jetzt sudo fuer rsync - rsync_manager: --numeric-ids Flag hinzugefuegt fuer korrekte UID/GID - snapshot_manager: mkdir mit sudo fuer Root-Besitz der Snapshots - snapshot_manager: delete_snapshot mit sudo (Snapshots sind Root-owned) - main_window: Sudo-Passwort-Dialog vor jedem Backup - main_window: Dialog-Text erweitert (Backup erfordert sudo) - main.cpp: --sudo-password Argument fuer CLI/Cron-Modus - main.cpp: Interaktive Passwort-Eingabe im CLI-Modus - README.md: Build-Abhaengigkeiten fuer alle Distros hinzugefuegt - README.md: Rechte-Tabelle aktualisiert - README.md: Cronjob-Beispiel mit Passwort-Speicherung aktualisiert Betroffene Dateien: src/rsync_manager.h, src/rsync_manager.cpp src/snapshot_manager.h, src/snapshot_manager.cpp src/main_window.h, src/main_window.cpp src/main.cpp README.md
266 lines
9.1 KiB
Markdown
266 lines
9.1 KiB
Markdown
# x3-Backup
|
||
|
||
GTK3 Backup/Snapshot-Tool mit rsync Backend.
|
||
|
||
Erstellt platzsparende Snapshots via Hardlink-Delta, durchstoebern und wiederherstellen von Einzeldateien oder ganzen Systemen.
|
||
|
||
## Features
|
||
|
||
- **rsync Snapshots** — Hardlink-Delta fuer platzsparende inkrementelle Backups
|
||
- **Snapshot Sidebar** — Alle Snapshots chronologisch sortiert
|
||
- **File Browser** — Dateien/Ordner durchsuchen mit Berechtigungen (rwx)
|
||
- **Restore** — Einzeldateien oder ganze Verzeichnisse wiederherstellen
|
||
- **System Tray** — Icon im Panel mit Status und Kontextmenue
|
||
- **Live Log** — Echtzeit-Ausgabe waehrend Backup/Restore
|
||
- **History Log** — Komplettes Log durchsuchbar
|
||
- **Cronjob** — Geplante Backups direkt aus dem Programm
|
||
- **System Backup** — Komplettes Root-Filesystem sichern
|
||
- **System Restore** — Aus Live-ISO wiederherstellen
|
||
- **CLI Modus** — `--backup`, `--system-backup` fuer Cron/Automation
|
||
|
||
## Installation
|
||
|
||
```bash
|
||
autoreconf -fi
|
||
./configure
|
||
make -j$(nproc)
|
||
sudo make install
|
||
```
|
||
|
||
Oder lokal bauen und starten:
|
||
```bash
|
||
autoreconf -fi && ./configure && make -j$(nproc)
|
||
./src/x3-backup
|
||
```
|
||
|
||
## Deinstallation
|
||
|
||
```bash
|
||
sudo ./uninstall.sh
|
||
```
|
||
|
||
## Layout
|
||
|
||
```
|
||
+------------------------------------------------------------------+
|
||
| x3-Backup [─] [□] [×] |
|
||
+------------------------------------------------------------------+
|
||
| File | Backup | System | Help |
|
||
+------------------------------------------------------------------+
|
||
| [New Backup] [Restore] [Delete] | [Settings] [========] 0% |
|
||
+------------------------------------------------------------------+
|
||
| | |
|
||
| Snapshots | [↑] [/home/user/documents] |
|
||
| | Select a snapshot to browse |
|
||
| ┌────────┐ | ┌──────────────────────────────────────────────────┐|
|
||
| │2026-09 │ | │ Name │ Size │ Permissions │ Modified │|
|
||
| │07 16:30│ | ├─────────────────┼────────┼─────────────┼──────────┤|
|
||
| │ │ | │ Documents │ - │ drwxr-xr-x │ │|
|
||
| ├────────┤ | │ Pictures │ - │ drwxr-xr-x │ │|
|
||
| │2026-09 │ | │ .bashrc │ 3.4 KB │ -rw-r--r-- │ │|
|
||
| │06 02:00│ | │ .ssh │ - │ drwx------ │ │|
|
||
| │ │ | │ notes.txt │ 12 KB │ -rw-r--r-- │ │|
|
||
| ├────────┤ | │ config.json │ 1.2 KB │ -rw-r--r-- │ │|
|
||
| │2026-09 │ | └──────────────────────────────────────────────────┘|
|
||
| │05 02:00│ | |
|
||
| └────────┘ | ┌──────────────────────────────────────────────────┐|
|
||
| | │ Live Log: │|
|
||
| | │ [cmd] rsync -aAX --info=progress2 --delete ... │|
|
||
| | │ [info] Syncing: /home/user/Documents/project/ │|
|
||
| | │ [done] Snapshot created: 2026-09-07_16-30-00 │|
|
||
| | │ │|
|
||
| | │ [Clear] │|
|
||
| | └──────────────────────────────────────────────────┘|
|
||
+------------------------------------------------------------------+
|
||
| x3-Backup - Idle Status Message|
|
||
+------------------------------------------------------------------+
|
||
```
|
||
|
||
## Dateisystem-Struktur
|
||
|
||
### Konfiguration
|
||
|
||
```
|
||
~/.config/x3-backup/
|
||
├── settings.json # Einstellungen
|
||
├── x3-backup.log # Log-Datei
|
||
```
|
||
|
||
### Backup-Destination
|
||
|
||
```
|
||
/mnt/backups/ # oder konfigurierter Pfad
|
||
├── snapshots/
|
||
│ ├── 2026-09-07_16-30-00/ # Snapshot 1 (Hardlinks)
|
||
│ │ ├── home/
|
||
│ │ │ └── user/
|
||
│ │ │ ├── documents/
|
||
│ │ │ ├── .bashrc
|
||
│ │ │ └── ...
|
||
│ │ ├── etc/
|
||
│ │ └── ...
|
||
│ ├── 2026-09-06_02-00-00/ # Snapshot 2 (nur Aenderungen)
|
||
│ │ └── ...
|
||
│ └── 2026-09-05_02-00-00/ # Snapshot 3 (aehnlich)
|
||
│ └── ...
|
||
└── metadata/
|
||
├── 2026-09-07_16-30-00.json # Metadaten
|
||
├── 2026-09-06_02-00-00.json
|
||
└── 2026-09-05_02-00-00.json
|
||
```
|
||
|
||
### Hardlink-Prinzip
|
||
|
||
```
|
||
Snapshot 1 (voll): Snapshot 2 (delta):
|
||
fileA (100KB) ──inode1 fileA (100KB) ──inode1 (identisch, Hardlink)
|
||
fileB (50KB) ──inode2 fileB (75KB) ──inode3 (geaendert, neue Datei)
|
||
fileC (200KB) ──inode3 fileC (200KB) ──inode3 (identisch, Hardlink)
|
||
fileD (30KB) ──inode4 (neu)
|
||
|
||
Platzbedarf: voll + delta (statt 2x voll)
|
||
```
|
||
|
||
## Config (settings.json)
|
||
|
||
```json
|
||
{
|
||
"backup_dest": "/mnt/backups",
|
||
"source_path": "/",
|
||
"exclude_patterns": [
|
||
"/mnt",
|
||
"/proc",
|
||
"/sys",
|
||
"/dev",
|
||
"/run",
|
||
"/tmp",
|
||
"/lost+found"
|
||
],
|
||
"preserve_permissions": true,
|
||
"preserve_acls": true,
|
||
"preserve_xattrs": true,
|
||
"delete_removed": true,
|
||
"retention_days": 30,
|
||
"retention_count": 10,
|
||
"cron_enabled": false,
|
||
"cron_schedule": "0 2 * * *",
|
||
"cron_label": "x3-backup-auto"
|
||
}
|
||
```
|
||
|
||
## CLI Nutzung
|
||
|
||
```bash
|
||
# Backup jetzt erstellen (fragt nach sudo-Passwort)
|
||
x3-backup --backup
|
||
|
||
# Backup mit Passwort-Argument (z.B. fuer Cron)
|
||
x3-backup --backup --sudo-password "DEIN_PASSWORT"
|
||
|
||
# System-Backup (von Live-ISO)
|
||
x3-backup --system-backup --sudo-password "DEIN_PASSWORT"
|
||
|
||
# Log auf STDOUT ausgeben
|
||
x3-backup --backup --log
|
||
|
||
# Hilfe
|
||
x3-backup --help
|
||
```
|
||
|
||
## Cronjob Beispiel
|
||
|
||
```bash
|
||
# WICHTIG: Sudo-Passwort in Datei speichern fuer Cron:
|
||
echo "DEIN_PASSWORT" > ~/.config/x3-backup/cron-pw.conf
|
||
chmod 600 ~/.config/x3-backup/cron-pw.conf
|
||
|
||
# Script fuer Cron erstellen:
|
||
cat > ~/.config/x3-backup/run-backup.sh << 'EOF'
|
||
#!/bin/bash
|
||
PW=$(cat ~/.config/x3-backup/cron-pw.conf 2>/dev/null)
|
||
/usr/local/bin/x3-backup --backup --sudo-password "$PW" >> ~/.config/x3-backup/x3-backup.log 2>&1
|
||
EOF
|
||
chmod +x ~/.config/x3-backup/run-backup.sh
|
||
|
||
# Taeglich um 2:00 Uhr
|
||
0 2 * * * ~/.config/x3-backup/run-backup.sh
|
||
|
||
# Alle 6 Stunden
|
||
0 */6 * * * ~/.config/x3-backup/run-backup.sh
|
||
|
||
# Woechentlich Sonntag 3:00 Uhr
|
||
0 3 * * 0 ~/.config/x3-backup/run-backup.sh
|
||
```
|
||
|
||
## Log Format
|
||
|
||
```
|
||
[2026-09-07 16:30:00] [INFO] x3-backup: === x3-backup started ===
|
||
[2026-09-07 16:30:00] [INFO] x3-backup: Log file: ~/.config/x3-backup/x3-backup.log
|
||
[2026-09-07 16:30:01] [INFO] x3-backup: rsync cmd: rsync -aAX --info=progress2 ...
|
||
[2026-09-07 16:30:15] [INFO] x3-backup: [done] Snapshot created: 2026-09-07_16-30-00
|
||
```
|
||
|
||
## Rechte und Wiederherstellung
|
||
|
||
| Aktion | Benoetigte Rechte |
|
||
|---|---|
|
||
| Backup erstellen | sudo (fuer korrekte Berechtigungen) |
|
||
| Datei wiederherstellen | sudo (fuer Root-Berechtigungen) |
|
||
| System wiederherstellen | sudo |
|
||
| Cronjob installieren | Normaler User (crontab -e) |
|
||
|
||
**Wichtig:** Backups werden mit sudo ausgefuehrt, um alle Dateiberechtigungen (UID/GID, rwx, ACLs, xattrs)
|
||
rekursiv korrekt zu uebernehmen. Ohne sudo waere das Backup unvollstaendig, da Root-Dateien nicht
|
||
gelesen und Berechtigungen nicht preserve werden koennen.
|
||
|
||
## Abhaengigkeiten
|
||
|
||
### Build-Abhaengigkeiten
|
||
|
||
**Ubuntu / Debian:**
|
||
```bash
|
||
sudo apt install build-essential autoconf automake pkg-config libgtk-3-dev libjson-glib-dev rsync
|
||
```
|
||
|
||
**Arch Linux:**
|
||
```bash
|
||
sudo pacman -S base-devel gtk3 json-glib rsync
|
||
```
|
||
|
||
**Gentoo Linux:**
|
||
```bash
|
||
sudo emerge --ask dev-build/autoconf dev-build/automake dev-util/pkgconfig x11-libs/gtk+:3 dev-libs/json-glib net-misc/rsync
|
||
```
|
||
|
||
**openSUSE:**
|
||
```bash
|
||
sudo zypper install -y gcc-c++ autoconf automake pkg-config gtk3-devel json-glib-devel rsync
|
||
```
|
||
|
||
**Fedora:**
|
||
```bash
|
||
sudo dnf install gcc-c++ autoconf automake pkgconfig gtk3-devel json-glib-devel rsync
|
||
```
|
||
|
||
### Laufzeit-Abhaengigkeiten
|
||
|
||
- GTK+ 3.0 (>= 3.24)
|
||
- json-glib-1.0
|
||
- rsync
|
||
- sudo (fuer Root-Rechte bei Backups)
|
||
- crontab (optional, fuer geplante Backups)
|
||
|
||
## Architektur
|
||
|
||
```
|
||
┌─────────────┐ ┌──────────────┐ ┌──────────────┐
|
||
│ MainWindow │───▶│SnapshotManager│───▶│ RsyncManager │
|
||
│ (GTK UI) │ │ (Snapshots) │ │ (rsync) │
|
||
└──────┬──────┘ └──────────────┘ └──────────────┘
|
||
│
|
||
├── SystemTray (Tray-Icon)
|
||
├── SettingsDialog (Einstellungen)
|
||
└── Config (JSON)
|
||
```
|