Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
en:backup:server [2022/02/26 02:22] – [Exclude folder and files] changed header dan | en:backup:server [2022/07/05 19:24] – [Script] -- prevent DokuWiki markup from rendering dan | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Server & desktop backup solutions ====== | ====== Server & desktop backup solutions ====== | ||
+ | The first backups will take a while. The following ones are much faster, but it depends on how much you change. Only the changes are saved. | ||
===== rsync ===== | ===== rsync ===== | ||
Line 109: | Line 110: | ||
===== borg ===== | ===== borg ===== | ||
- | |||
- | <alert type=" | ||
Follow our [[en: | Follow our [[en: | ||
Line 116: | Line 115: | ||
The snapshots are stored remotely via ssh. | The snapshots are stored remotely via ssh. | ||
+ | ==== Script ==== | ||
- | ===== Crontab ===== | + | Don't forget to create the borg repo first and add the credentials to the script. |
+ | < | ||
+ | borg init --encryption=keyfile-blake2 --make-parent-dirs ssh:// | ||
+ | </ | ||
+ | |||
+ | Add your excluded folders/ | ||
+ | < | ||
+ | #!/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 | ||
Follow our [[en: | Follow our [[en: | ||
Line 123: | Line 200: | ||
< | < | ||
@daily / | @daily / | ||
+ | </ | ||
+ | < | ||
+ | @daily / | ||
</ | </ | ||
Line 132: | Line 212: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | |||
+ | |||
+ | ===== Syncthing ===== | ||
+ | |||
+ | Follow our [[en: | ||
+ | |||
+ | |||
+ | ==== Add device ==== | ||
+ | |||
+ | Add the backup server to your client under '' | ||
+ | |||
+ | |||
+ | ==== Add folder ==== | ||
+ | |||
+ | * Add a folder under '' | ||
+ | * Select your backup server under '' | ||
+ | * Under '' | ||
+ | * Also check '' | ||
+ | |||
+ | |||
+ | |||
+ | |||