Files

230 lines
4.7 KiB
Markdown

# Timeshift Kommandozeilen-Nutzung
## Überblick
Timeshift ist ein Backup-Tool für Linux-Systeme, das System-Snapshots erstellt. Es kann sowohl über eine grafische Oberfläche als auch über die Kommandozeile verwendet werden.
## Installation
```bash
# Ubuntu/Debian
sudo apt update && sudo apt install timeshift
# Arch Linux
sudo pacman -S timeshift
# Fedora/CentOS
sudo dnf install timeshift
```
## Grundlegende Konfiguration
### Initialisierung
```bash
# Timeshift einrichten (wählt automatisch RSYNC oder BTRFS)
sudo timeshift --check
# Konfiguration anzeigen
sudo timeshift --list-config
```
### Backup-Typ festlegen
```bash
# RSYNC-Modus (Standard für ext4)
sudo timeshift --rsync
# BTRFS-Modus (für BTRFS-Dateisysteme)
sudo timeshift --btrfs
```
## Snapshots erstellen
### Manuellen Snapshot erstellen
```bash
# Einfacher Snapshot
sudo timeshift --create
# Snapshot mit Kommentar
sudo timeshift --create --comments "Vor System-Update"
# Snapshot mit spezifischem Namen
sudo timeshift --create --comments "Pre-Kernel-Update-$(date +%Y%m%d)"
```
### Automatische Snapshots konfigurieren
```bash
# Tägliche Snapshots aktivieren
sudo timeshift --snapshot-device /dev/sda1 --schedule-daily
# Wöchentliche Snapshots
sudo timeshift --schedule-weekly
# Monatliche Snapshots
sudo timeshift --schedule-monthly
```
## Snapshots verwalten
### Snapshots auflisten
```bash
# Alle verfügbaren Snapshots anzeigen
sudo timeshift --list
# Detaillierte Liste
sudo timeshift --list --verbose
```
### Snapshot-Informationen anzeigen
```bash
# Informationen zu einem spezifischen Snapshot
sudo timeshift --list | grep "2024-01-15"
```
## System wiederherstellen
### Komplette Systemwiederherstellung
```bash
# Neuesten Snapshot wiederherstellen
sudo timeshift --restore
# Spezifischen Snapshot wiederherstellen
sudo timeshift --restore --snapshot "2024-01-15_18-30-45"
# Wiederherstellung mit Bestätigung
sudo timeshift --restore --snapshot "2024-01-15_18-30-45" --skip-grub
```
### Einzelne Dateien wiederherstellen
```bash
# Snapshot mounten (nur-lesen)
sudo timeshift --restore --snapshot "2024-01-15_18-30-45" --clone
# Dann Dateien manuell kopieren
cp /timeshift/snapshots/2024-01-15_18-30-45/localhost/path/to/file /original/path/
```
## TTY-Sitzung (Notfall-Wiederherstellung)
### Zugang zur TTY
```bash
# Wechsel zu TTY (Strg+Alt+F1 bis F6)
# Oder über SSH wenn verfügbar
```
### Wiederherstellung in TTY
```bash
# 1. Als root anmelden
sudo su -
# 2. Snapshots auflisten
timeshift --list
# 3. System wiederherstellen
timeshift --restore --snapshot "SNAPSHOT_NAME"
# 4. System neustarten
reboot
```
### Notfall-Boot von Live-USB
```bash
# 1. Live-USB booten
# 2. Festplatte mounten
sudo mount /dev/sda1 /mnt
# 3. Timeshift auf Live-System installieren
sudo apt update && sudo apt install timeshift
# 4. Wiederherstellung auf gemountete Partition
sudo timeshift --restore --target-device /dev/sda1
```
## Nützliche Optionen
### Backup-Ausschlüsse konfigurieren
```bash
# Bestimmte Verzeichnisse ausschließen
sudo timeshift --exclude /home/user/Downloads
sudo timeshift --exclude /tmp
sudo timeshift --exclude /var/cache
```
### Aufbewahrungsrichtlinien
```bash
# Maximale Anzahl Snapshots begrenzen
sudo timeshift --max-snapshots 5
# Alte Snapshots automatisch löschen
sudo timeshift --delete-old
```
### Snapshot löschen
```bash
# Spezifischen Snapshot löschen
sudo timeshift --delete --snapshot "2024-01-15_18-30-45"
# Alle bis auf die letzten 3 löschen
sudo timeshift --delete-old --max-snapshots 3
```
## Automatisierung mit Cron
### Tägliche Backups einrichten
```bash
# Crontab bearbeiten
sudo crontab -e
# Tägliches Backup um 2:00 Uhr
0 2 * * * /usr/bin/timeshift --create --comments "Daily-Auto-$(date +\%Y\%m\%d)" && /usr/bin/timeshift --delete-old --max-snapshots 7
```
## Monitoring und Logs
### Status überprüfen
```bash
# Timeshift-Status
sudo timeshift --check
# Logs anzeigen
sudo journalctl -u timeshift
tail -f /var/log/timeshift.log
```
### Speicherplatz überwachen
```bash
# Snapshot-Größen anzeigen
du -sh /timeshift/snapshots/*
# Verfügbaren Speicher prüfen
df -h /timeshift
```
## Troubleshooting
### Häufige Probleme
```bash
# Berechtigungen reparieren
sudo timeshift --check
# Cache leeren
sudo rm -rf /tmp/timeshift*
# Snapshot-Index reparieren
sudo timeshift --delete-old --scripted
```
### Recovery bei korrupten Snapshots
```bash
# Snapshot-Konsistenz prüfen
sudo timeshift --list --check-snapshots
# Defekte Snapshots entfernen
sudo timeshift --delete --snapshot "CORRUPT_SNAPSHOT"
```
---
**Wichtige Hinweise:**
- Immer mit `sudo` ausführen
- Vor wichtigen Systemänderungen Snapshots erstellen
- Regelmäßig alte Snapshots löschen (Speicherplatz)
- Bei BTRFS-Systemen BTRFS-Modus verwenden
- Boot-Snapshots für kritische Updates erstellen