Benutzer-Werkzeuge

Webseiten-Werkzeuge


infrastruktur:host:billy

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige ÜberarbeitungVorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
infrastruktur:host:billy [26.08.2024 02:16] – [Einrichtung Client für Backups] Linus Lüssinginfrastruktur: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 (Solibeitrag?).
  
 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:host:billy:setup]]+Einrichtung von billy, dem BorgBackup server auf Case: [[infrastruktur:host:billy:billy-borg-server-setup]]
  
 ===== Einrichtung Client für Backups ===== ===== Einrichtung Client für Backups =====
  
-==== Initialisierung: SSH ==== +Einrichtung eines Client-Gerätes zur Nutzung von BorgBackup auf billy: [[infrastruktur:host:billy:billy-borg-client-setup]]
- +
-Anmerkung: Ersetze "tux" in folgendem mit deinem Nutzernamen im LDAP. +
- +
-Erzeuge einen SSH Schlüssel, mit dem dein borg client im Hintergrund später die Backups machen darf: +
- +
-<code> +
-$ ssh-keygen -f ~/.ssh/id_ed25519_billyborg +
-</code> +
- +
-Füge willi und billy ähnlich wie folgt in deine ~/.ssh/config hinzu: +
- +
-**~/.ssh/config**: +
-<code> +
-Host willi +
-        User tux  +
-        Hostname willi.nobreakspace.org +
- IdentityFile ~/.ssh/id_ed25519_billyborg +
- +
-Host billyborg +
-        Hostname billy.nobreakspace.org +
-        User tux  +
- IdentityFile ~/.ssh/id_ed25519_billyborg +
-        ProxyCommand ssh -4 willi -o ControlMaster=no -W "[%h]":%p +
-</code> +
- +
-Nun installiere den public key deines neuen SSH keys auf willi und billi: +
- +
-<code> +
-$ ssh-copy-id -i ~/.ssh/id_ed25519_billyborg tux@willi.nobreakspace.org +
-$ cat ~/.ssh/id_ed25519_billyborg.pub | ssh billyborg ssh-add-authorized-keys +
-</code> +
- +
-==== Initialisierung: Borg Repository ==== +
- +
-Initilisiere dein Borg auf billy: +
- +
-<code> +
-$ borg init --encryption=keyfile ssh://billyborg/~/home +
-</code> +
- +
-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 ==== +
- +
-<code> +
-#!/bin/sh +
- +
-export BORG_REPO=ssh://billyborg/~/home +
-export BORG_PASSPHRASE="<dein-super-passwort>" +
- +
-# some helpers and error handling: +
-info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; } +
-trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM +
- +
-info "Starting backup" +
- +
-# --dry-run \ +
-borg create \ +
- --verbose                       \ +
- --filter AME                    \ +
- --list                          \ +
- --stats                         \ +
- --show-rc                       \ +
- --compression lz4               \ +
- --exclude-caches                \ +
- --exclude "${HOME}/borg/logs/"+
- --exclude "${HOME}/.cache/"+
- --exclude "${HOME}/.ccache/"+
- --exclude "${HOME}/.local/share/Trash/"+
- --exclude "${HOME}/.electron-gyp/"+
- --exclude "${HOME}/.config/Electron/Cache/"+
- --exclude "${HOME}/.tmp/"+
- --exclude "${HOME}/.mnt/"+
- --exclude "${HOME}/.pub-cache/"+
- --exclude "${HOME}/.steam/"+
- --exclude "${HOME}/Games/"+
- --exclude "${HOME}/.android/cache/"+
- --exclude "${HOME}/backup/"+
- --exclude "${HOME}/Musik/dnb-vids/*.mkv"+
- --exclude "${HOME}/Downloads/"+
- --exclude "${HOME}/Desktop/"+
- --exclude "${HOME}/Videos/"+
- --exclude "${HOME}/dev/linux/*.deb"+
- --exclude "${HOME}/dev/linux/linux/*.deb"+
- --exclude "${HOME}/dev/linux/*.gz"+
- --exclude "${HOME}/dev/linux/linux/*.gz"+
- --exclude "${HOME}/dev/**/build_dir/"+
- --exclude "${HOME}/dev/gluon*/output*/"+
- --exclude "${HOME}/dev/gluon-*dl/"+
- --exclude "${HOME}/dev/gluon-*dl-old/"+
- --exclude "${HOME}/dev/gluon-*dl-old*/"+
- --exclude "${HOME}/dev/openwrt-*dl/"+
- --exclude "${HOME}/dev/**/__pycache__/**/"+
- --exclude "${HOME}/dev/**/build_dir/"+
- --exclude "${HOME}/dev/**/staging_dir/"+
- --exclude "${HOME}/dev/**/bin/"+
- --exclude "${HOME}/dev/**/tmp/"+
- --exclude "${HOME}/dev/**/*.o"+
- --exclude "${HOME}/dev/**/*.ko"+
- --exclude "${HOME}/dev/**/*.mod.c"+
-+
- ::'{hostname}-{now}'+
- ${HOME}/ +
- +
-backup_exit=$? +
- +
-info "Pruning repository" +
- +
-# Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly +
-# archives of THIS machine. The '{hostname}-' prefix is very important to +
-# limit prune's operation to this machine's archives and not apply to +
-# other machines' archives also: +
- +
-borg prune                          \ +
-    --list                          \ +
-    --prefix '{hostname}-'          \ +
-    --show-rc                       \ +
-    --keep-daily    7               \ +
-    --keep-weekly                 \ +
-    --keep-monthly  6               \ +
-    --keep-yearly   10 +
- +
-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 "Backup and/or Prune finished with a warning" +
-fi +
- +
-if [ ${global_exit} -gt 1 ]; +
-then +
-    info "Backup and/or Prune finished with an error" +
-fi +
- +
-exit ${global_exit} +
-</code> +
- +
-==== Automatische Backups per systemd timer ==== +
- +
-<code> +
-$ mkdir -p ~/borg/logs +
-</code> +
- +
-**~/.config/systemd/user/borg-backup-billy.service** +
-<code> +
-[Unit] +
-Description=Borg Backup +
-Conflicts=shutdown.target +
-#StartLimitIntervalSec=20h +
-#StartLimitBurst=5 +
- +
-[Service] +
-Type=oneshot +
-ExecStart=%h/.local/bin/borg-backup-billy.sh +
-Restart=on-failure +
-RestartSec=30min +
-StandardOutput=append:%h/borg/logs/borg.log +
-StandardError=append:%h/borg/logs/borg.err +
-Nice=15 +
-IOSchedulingClass=best-effort +
-IOSchedulingPriority=7 +
-</code> +
- +
-**~/.config/systemd/user/borg-backup-billy.timer** +
-<code> +
-[Unit] +
-Description=Run Borg Backup daily and on boot +
- +
-[Timer] +
-OnBootSec=15min +
-OnUnitActiveSec=1d +
- +
-[Install] +
-WantedBy=timers.target +
-</code> +
- +
-... +
- +
-Überprüfe, inbesondere auch nach einem Neustart: +
- +
-<code> +
-$ systemctl list-timers +
-</code> +
- +
-Überprüfe auch, ob in ~/borg/logs/borg.err Fehler auftreten. Falls dies der Fall sein sollte, wird borg / systemd dies alle 30 Minuten erneunt versuchen, statt bloß einmal pro Tag. Auslöser hierfür kann auch / oft einfach eine kleine (übersprungene) Datei mit fehlenden Leserechten sein. +
- +
-==== (Vor)Letzter Check: Backups überprüfen ==== +
- +
-<code> +
-$ mkdir /tmp/borgmount +
-$ borgfs ssh://billyborg/~/home /tmp/borgmount +
-</code> +
- +
-Prüfe nun, ob du in /tmp/borgmount/... deine Dateien wieder findest und auslesen kannst. Manchmal kann das Öffnen einer Datei oder Ordners beim ersten Versuch etwas dauern, bis Daten von billy wieder zurück übertragen und gecached wurden. +
- +
-Zu letzt wieder schließen mit: +
- +
-<code> +
-$ umount /tmp/borgmount +
-</code> +
- +
-==== Allerletzter Check: Backups mit ausgedruckten Schlüssel wiederherstellen ==== +
- +
-ToDo+
infrastruktur/host/billy.1724638595.txt.gz · Zuletzt geändert: 26.08.2024 02:16 von Linus Lüssing