|
|
borg backup
|
|
|
==========
|
|
|
# Backup
|
|
|
|
|
|
Wir nutzen [borg backup](https://borgbackup.readthedocs.io/en/stable/) für Backups vom m18-Server auf jambalaya.
|
|
|
Im StuKo-Büro in der m18 steht der backup-Server acedia.stuko.uni-weimar.de.
|
|
|
|
|
|
# Installation
|
|
|
Backups über [zrepl](https://zrepl.github.io/index.html). Installation/Repository: <https://zrepl.github.io/installation/apt-repos.html>
|
|
|
|
|
|
### borg backup
|
|
|
Config angepasst von <https://zrepl.github.io/quickstart/continuous_server_backup.html>
|
|
|
|
|
|
Aktuell nutzen wir Version 1.09 - neue Versionen kann man als Standalone Binary von [github](https://github.com/borgbackup/borg/releases) herunterladen.
|
|
|
Aktuelles Festplatten-Setup:
|
|
|
4x 2TB als zfs-pool zbackup
|
|
|
1x 80GB als Systemplatte (ext4)
|
|
|
|
|
|
# wget -O /usr/local/sbin/borg \
|
|
|
https://github.com/borgbackup/borg/releases/download/1.0.9/borg-linux64
|
|
|
# chmod +x /usr/local/sbin/borg
|
|
|
# borg -V
|
|
|
borg 1.0.9
|
|
|
Es ist Debian 12 installiert, ZFS-Support laut OpenZFS-Doku: <https://openzfs.github.io/openzfs-docs/Getting%20Started/Debian/index.html#installation>
|
|
|
|
|
|
### Backup Script
|
|
|
Monitoring für die Festplatten läuft über den [smartmontool-daemon](https://wiki.archlinux.org/title/S.M.A.R.T.), Mail-Benachrichtigungen über [dma](https://wiki.archlinux.org/title/Dma) und den Mail-Account backup@m18.uni-weimar.de.
|
|
|
|
|
|
```bash
|
|
|
# cat /root/borg-backup-m18.sh
|
|
|
#!/bin/sh
|
|
|
export REPOSITORY=ssh://borgbackup@ping01.stura.uni-weimar.de:2222/tank/m18-borg-backup
|
|
|
export BORG_PASSPHRASE=<passphrase>
|
|
|
|
|
|
# Backup all of /home and /var/www except a few
|
|
|
# excluded directories
|
|
|
/usr/local/sbin/borg create --compression=lz4 -v --stats \
|
|
|
$REPOSITORY::'{hostname}-{now:%Y-%m-%d}' \
|
|
|
/ \
|
|
|
--exclude /sys \
|
|
|
--exclude /dev \
|
|
|
--exclude /proc \
|
|
|
--exclude /tmp \
|
|
|
--exclude /var/tmp \
|
|
|
--exclude /mnt \
|
|
|
--exclude /media \
|
|
|
--exclude /selinux
|
|
|
|
|
|
# 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 machine's archives also.
|
|
|
/usr/local/sbin/borg prune -v --list $REPOSITORY --prefix '{hostname}-' \
|
|
|
--keep-daily=7 --keep-weekly=4 --keep-monthly=6
|
|
|
```
|
|
|
|
|
|
### cron
|
|
|
|
|
|
Tägliches Backup um 2:42Uhr via cron:
|
|
|
|
|
|
# crontab -e
|
|
|
|
|
|
Folgende Zeile hinzufügen:
|
|
|
|
|
|
42 2 * * * /root/borg-backup-m18.sh
|
|
|
|
|
|
### Jambalaya
|
|
|
|
|
|
es gibt den User `borgbackup` der auf das ZFS Dataset `tank/m18-borg-backup` zugreifen darf.
|
|
|
|
|
|
### SSH Keys
|
|
|
|
|
|
Auf dem m18 Server wird der Key `~/.ssh/id_ed25519` von root ohne Passwort für den Zugang auf jambalaya mit dem `borgbackup` genutzt.
|
|
|
|
|
|
Neuen SSH Key auf jambalaya hinzufügen:
|
|
|
|
|
|
# ssh-copy-id borgbackup@ping01.stura.uni-weimar.de -p 2222
|
|
|
|
|
|
# Check & Restore
|
|
|
|
|
|
Von jedem Rechner mit installiertem borg möglich
|
|
|
|
|
|
## Verfügbare Backups anzeigen
|
|
|
|
|
|
# borg list ssh://borgbackup@ping01.stura.uni-weimar.de:2222/tank/m18-borg-backup
|
|
|
Enter passphrase for key ssh://borgbackup@ping01.stura.uni-weimar.de:2222/tank/m18-borg-backup:
|
|
|
epithymetikon-2017-01-13 Fri, 2017-01-13 21:25:40
|
|
|
epithymetikon-2017-01-14 Sat, 2017-01-14 18:33:17
|
|
|
|
|
|
## Remote Backup überprüfen
|
|
|
|
|
|
# borg check\
|
|
|
ssh://borgbackup@ping01.stura.uni-weimar.de:2222/tank/m18-borg-backup::epithymetikon-2017-01-13
|
|
|
Remote: Checking segments 22.1%
|
|
|
|
|
|
## Remote Backup wiederherstellen
|
|
|
|
|
|
|
|
|
# borg extract \
|
|
|
ssh://borgbackup@ping01.stura.uni-weimar.de:2222/tank/m18-borg-backup::epithymetikon-2017-01-13 |
|
|
Unattended Upgrades sind eingerichtet, das **zrepl** package ist davon ausgenommen um *breaking changes* zu vermeiden und sollte entsprechend bei Bedarf manuell geupdatet werden. |
|
|
\ No newline at end of file |