Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
infrastruktur:host:billy [26.08.2024 02:16] – [Einrichtung Client für Backups] Linus Lüssing | infrastruktur:host:billy [05.09.2024 02:19] (aktuell) – ↷ Links angepasst weil Seiten im Wiki verschoben wurden Linus Lüssing | ||
---|---|---|---|
Zeile 17: | Zeile 17: | ||
Access auf den Host ist stark limitiert: Nur borg Befehle und `ssh-add-authorized-keys` sind erlaubt (näheres siehe unten). Keine Shell, kein forwarding, kein X11 etc. | Access auf den Host ist stark limitiert: Nur borg Befehle und `ssh-add-authorized-keys` sind erlaubt (näheres siehe unten). Keine Shell, kein forwarding, kein X11 etc. | ||
- | Für jeden User gibt es standardmäßig ein Speicherlimit von 250G (to be discussed). Bei aktuellen, günstigsten HDD Preisen (2024-08) wären dies 5€ bei voller Nutzung. | + | Für jeden User gibt es standardmäßig ein Speicherlimit von 250G (to be discussed). Bei aktuellen, günstigsten HDD Preisen (2024-08) wären dies 5€ bei voller Nutzung |
ES GIBT KEINE GARANTIE! DIE BACKUPS KÖNNEN VON HEUTE AUF MORGEN KAPUTT GEHEN! MISSBRAUCHE BORG NICHT ALS CLOUD STORAGE, DEINE EINZIGE KOPIE! NUTZE ES WIRKLICH NUR ALS BACKUP! | ES GIBT KEINE GARANTIE! DIE BACKUPS KÖNNEN VON HEUTE AUF MORGEN KAPUTT GEHEN! MISSBRAUCHE BORG NICHT ALS CLOUD STORAGE, DEINE EINZIGE KOPIE! NUTZE ES WIRKLICH NUR ALS BACKUP! | ||
Zeile 23: | Zeile 23: | ||
===== Einrichtungsdetails von Billy ===== | ===== Einrichtungsdetails von Billy ===== | ||
- | [[infrastruktur: | + | Einrichtung von billy, dem BorgBackup server auf Case: [[infrastruktur: |
===== Einrichtung Client für Backups ===== | ===== Einrichtung Client für Backups ===== | ||
- | ==== Initialisierung: | + | Einrichtung eines Client-Gerätes zur Nutzung von BorgBackup auf billy: [[infrastruktur:host: |
- | + | ||
- | Anmerkung: Ersetze " | + | |
- | + | ||
- | Erzeuge einen SSH Schlüssel, mit dem dein borg client im Hintergrund später die Backups machen darf: | + | |
- | + | ||
- | < | + | |
- | $ ssh-keygen -f ~/ | + | |
- | </ | + | |
- | + | ||
- | Füge willi und billy ähnlich wie folgt in deine ~/ | + | |
- | + | ||
- | **~/ | + | |
- | < | + | |
- | Host willi | + | |
- | User tux | + | |
- | Hostname willi.nobreakspace.org | + | |
- | IdentityFile ~/ | + | |
- | + | ||
- | Host billyborg | + | |
- | Hostname billy.nobreakspace.org | + | |
- | User tux | + | |
- | IdentityFile ~/ | + | |
- | ProxyCommand ssh -4 willi -o ControlMaster=no -W "[%h]":%p | + | |
- | </ | + | |
- | + | ||
- | Nun installiere den public key deines neuen SSH keys auf willi und billi: | + | |
- | + | ||
- | < | + | |
- | $ ssh-copy-id -i ~/ | + | |
- | $ cat ~/ | + | |
- | </ | + | |
- | + | ||
- | ==== Initialisierung: | + | |
- | + | ||
- | Initilisiere dein Borg auf billy: | + | |
- | + | ||
- | < | + | |
- | $ borg init --encryption=keyfile ssh:// | + | |
- | </ | + | |
- | + | ||
- | Exportiere und drucke wie vom obigen "borg init" Befehl empfohlen deinen Borg Schlüssel aus und bewahre ihn und das Passwort sicher und getrennt voneinander auf. | + | |
- | + | ||
- | WICHTIG: OHNE DIESE KOMMST DU SPÄTER NICHT MEHR AUF DEINE BACKUPS! | + | |
- | + | ||
- | ==== Borg Backup Script ==== | + | |
- | + | ||
- | < | + | |
- | #!/bin/sh | + | |
- | + | ||
- | export BORG_REPO=ssh:// | + | |
- | export BORG_PASSPHRASE="< | + | |
- | + | ||
- | # some helpers and error handling: | + | |
- | info() { printf "\n%s %s\n\n" | + | |
- | trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM | + | |
- | + | ||
- | info " | + | |
- | + | ||
- | # | + | |
- | borg create \ | + | |
- | --verbose | + | |
- | --filter AME \ | + | |
- | --list | + | |
- | --stats | + | |
- | --show-rc | + | |
- | --compression lz4 \ | + | |
- | --exclude-caches | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | --exclude " | + | |
- | \ | + | |
- | ::' | + | |
- | ${HOME}/ | + | |
- | + | ||
- | backup_exit=$? | + | |
- | + | ||
- | info " | + | |
- | + | ||
- | # Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly | + | |
- | # archives of THIS machine. The ' | + | |
- | # limit prune' | + | |
- | # other machines' | + | |
- | + | ||
- | borg prune \ | + | |
- | --list | + | |
- | --prefix ' | + | |
- | --show-rc | + | |
- | --keep-daily | + | |
- | --keep-weekly | + | |
- | --keep-monthly | + | |
- | --keep-yearly | + | |
- | + | ||
- | prune_exit=$? | + | |
- | + | ||
- | # use highest exit code as global exit code | + | |
- | global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit )) | + | |
- | + | ||
- | if [ ${global_exit} -eq 1 ]; | + | |
- | then | + | |
- | info " | + | |
- | fi | + | |
- | + | ||
- | if [ ${global_exit} -gt 1 ]; | + | |
- | then | + | |
- | info " | + | |
- | fi | + | |
- | + | ||
- | exit ${global_exit} | + | |
- | </ | + | |
- | + | ||
- | ==== Automatische Backups per systemd timer ==== | + | |
- | + | ||
- | < | + | |
- | $ mkdir -p ~/ | + | |
- | </ | + | |
- | + | ||
- | **~/ | + | |
- | < | + | |
- | [Unit] | + | |
- | Description=Borg Backup | + | |
- | Conflicts=shutdown.target | + | |
- | # | + | |
- | # | + | |
- | + | ||
- | [Service] | + | |
- | Type=oneshot | + | |
- | ExecStart=%h/ | + | |
- | Restart=on-failure | + | |
- | RestartSec=30min | + | |
- | StandardOutput=append: | + | |
- | StandardError=append: | + | |
- | Nice=15 | + | |
- | IOSchedulingClass=best-effort | + | |
- | IOSchedulingPriority=7 | + | |
- | </ | + | |
- | + | ||
- | **~/ | + | |
- | < | + | |
- | [Unit] | + | |
- | Description=Run Borg Backup daily and on boot | + | |
- | + | ||
- | [Timer] | + | |
- | OnBootSec=15min | + | |
- | OnUnitActiveSec=1d | + | |
- | + | ||
- | [Install] | + | |
- | WantedBy=timers.target | + | |
- | </ | + | |
- | + | ||
- | ... | + | |
- | + | ||
- | Überprüfe, | + | |
- | + | ||
- | < | + | |
- | $ systemctl list-timers | + | |
- | </ | + | |
- | + | ||
- | Überprüfe auch, ob in ~/ | + | |
- | + | ||
- | ==== (Vor)Letzter Check: Backups überprüfen ==== | + | |
- | + | ||
- | < | + | |
- | $ mkdir / | + | |
- | $ borgfs ssh:// | + | |
- | </ | + | |
- | + | ||
- | Prüfe nun, ob du in / | + | |
- | + | ||
- | Zu letzt wieder schließen mit: | + | |
- | + | ||
- | < | + | |
- | $ umount / | + | |
- | </ | + | |
- | + | ||
- | ==== Allerletzter Check: Backups mit ausgedruckten Schlüssel wiederherstellen ==== | + | |
- | + | ||
- | ToDo | + |