|
|
borg backup
|
|
|
==========
|
|
|
|
|
|
Wir nutzen [borg backup](https://borgbackup.readthedocs.io/en/stable/) für Backups vom m18-Server auf jambalaya.
|
|
|
|
|
|
# Installation
|
|
|
|
|
|
### borg backup
|
|
|
|
|
|
Aktuell nutzen wir Version 1.09 - neue Versionen kann man als Standalone Binary von [github](https://github.com/borgbackup/borg/releases) herunterladen.
|
|
|
|
|
|
# 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
|
|
|
|
|
|
### Backup Script
|
|
|
|
|
|
```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 ist der `id_ed25519` von root ohne Passwort ist für den user `borgbackup` hinterlegt.
|
|
|
|
|
|
|
|
|
# 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 |