Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
de:scans:backup:server [2022/09/02 23:45] – removed - external edit (Unknown date) 127.0.0.1 | de:backup:server [2022/10/24 08:24] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Server & Desktop Backup-Lösungen ====== | ||
+ | |||
+ | Die ersten Sicherungen werden eine Weile dauern. Die folgenden sind viel schneller, aber das hängt davon ab, wie viel geändert wurde. Es werden nur die Änderungen gespeichert. | ||
+ | |||
+ | ===== rsync ===== | ||
+ | |||
+ | Folge zunächst unserer [[de: | ||
+ | |||
+ | Die Snapshots werden lokal und über die rsync-Daemon remote gespeichert. | ||
+ | |||
+ | <alert type=" | ||
+ | |||
+ | ==== Abhängigkeiten ==== | ||
+ | |||
+ | Das Skript benötigt '' | ||
+ | |||
+ | < | ||
+ | pacman -S inetutils | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Anmeldeinformationen ==== | ||
+ | |||
+ | < | ||
+ | echo " | ||
+ | chmod 400 / | ||
+ | </ | ||
+ | |||
+ | ==== Skript ==== | ||
+ | |||
+ | Füge deine Daten zu '' | ||
+ | |||
+ | < | ||
+ | nano / | ||
+ | </ | ||
+ | < | ||
+ | #!/bin/sh | ||
+ | |||
+ | ## Based on: | ||
+ | ## my own rsync-based snapshot-style backup procedure | ||
+ | ## (cc) marcio rps AT gmail.com | ||
+ | |||
+ | # config vars | ||
+ | |||
+ | SRC="/" | ||
+ | SNAP="/ | ||
+ | OPTS=" | ||
+ | EXCL=" | ||
+ | DAEMONUSER="" | ||
+ | DAEMONHOST="" | ||
+ | HOSTNAME=$(hostname) | ||
+ | MINCHANGES=1 | ||
+ | |||
+ | # run this process with real low priority | ||
+ | |||
+ | ionice -c 3 -p $$ | ||
+ | renice +12 -p $$ | ||
+ | |||
+ | # List and save installed packages | ||
+ | pacman -Qn | awk '{ print $1 }' > / | ||
+ | |||
+ | # sync | ||
+ | |||
+ | rsync $OPTS $EXCL $SRC $SNAP/ | ||
+ | |||
+ | # check if enough has changed and if so | ||
+ | # make a hardlinked copy named as the date | ||
+ | |||
+ | COUNT=$( wc -l $SNAP/ | ||
+ | if [ $COUNT -gt $MINCHANGES ] ; then | ||
+ | DATETAG=$(date +%Y-%m-%d-%H: | ||
+ | if [ ! -e $SNAP/ | ||
+ | cp -al $SNAP/ | ||
+ | chmod u+w $SNAP/ | ||
+ | mv $SNAP/ | ||
+ | chmod u-w $SNAP/ | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | rsync -avAXHP --delete --password-file=/ | ||
+ | </ | ||
+ | < | ||
+ | chmod +x / | ||
+ | </ | ||
+ | |||
+ | |||
+ | === Ordner und Dateien ausschließen === | ||
+ | |||
+ | Dies ist ein Beispiel. Füge alles hinzu, was du nicht sichern möchtest. Und ändere den home '' | ||
+ | |||
+ | < | ||
+ | nano / | ||
+ | </ | ||
+ | < | ||
+ | /dev/* | ||
+ | /proc/* | ||
+ | /sys/* | ||
+ | /tmp/* | ||
+ | /run/* | ||
+ | /mnt/* | ||
+ | /media/* | ||
+ | /lost+found | ||
+ | # root user | ||
+ | / | ||
+ | / | ||
+ | # Home user | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== borg ===== | ||
+ | |||
+ | Folge zunächst unserem [[de: | ||
+ | |||
+ | Die Snapshots werden über SSH gespeichert. | ||
+ | |||
+ | ==== Skript ==== | ||
+ | |||
+ | Vergiss nicht, zuerst das Borg Repo zu erstellen und dem Skript die Anmeldedaten hinzuzufügen. | ||
+ | < | ||
+ | borg init --encryption=keyfile-blake2 --make-parent-dirs ssh:// | ||
+ | </ | ||
+ | |||
+ | Füge deine ausgeschlossenen Ordner/ | ||
+ | |||
+ | < | ||
+ | #!/bin/sh | ||
+ | |||
+ | # Setting this, so the repo does not need to be given on the commandline: | ||
+ | export BORG_REPO=ssh:// | ||
+ | |||
+ | # See the section " | ||
+ | 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 " | ||
+ | |||
+ | # Backup the most important directories into an archive named after | ||
+ | # the machine this script is currently running on: | ||
+ | |||
+ | borg create | ||
+ | --verbose | ||
+ | --filter AMEhsx | ||
+ | --list | ||
+ | --stats | ||
+ | --progress | ||
+ | --verbose | ||
+ | --show-version | ||
+ | --show-rc | ||
+ | --compression zstd, | ||
+ | --exclude-caches | ||
+ | --exclude '/ | ||
+ | --exclude '/ | ||
+ | \ | ||
+ | ::' | ||
+ | /etc \ | ||
+ | /home \ | ||
+ | /root \ | ||
+ | /var \ | ||
+ | |||
+ | 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 0 ]; then | ||
+ | info " | ||
+ | elif [ ${global_exit} -eq 1 ]; then | ||
+ | info " | ||
+ | else | ||
+ | info " | ||
+ | fi | ||
+ | |||
+ | exit ${global_exit} | ||
+ | </ | ||
+ | ===== Crontab - rsync und borg ===== | ||
+ | |||
+ | Folge zunächst unserem [[de: | ||
+ | |||
+ | < | ||
+ | @daily / | ||
+ | </ | ||
+ | < | ||
+ | @daily / | ||
+ | </ | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | |||
+ | ===== Syncthing ===== | ||
+ | |||
+ | Folge zunächst unserem [[de: | ||
+ | |||
+ | |||
+ | ==== Gerät hinzufügen ==== | ||
+ | |||
+ | Füge den Backupserver zu deinem Client unter '' | ||
+ | |||
+ | |||
+ | ==== Ordner hinzufügen ==== | ||
+ | |||
+ | * Füge einen Ordner unter '' | ||
+ | * Wähle unter '' | ||
+ | * Unter '' | ||
+ | * Check auch '' | ||
+ | |||