Restic

Restic en quelques exemples

Pour initialiser un repository sur un serveur rest

restic -r rest:https://user:pwd@server:8000/user init

Pour sauver un backup sur un serveur rest

restic -r rest:https://user:pwd@server:8000/user backup --limit-upload=1500 -p password.txt /source

Attention, le :8000/user doit correspondre au login de la connexion user:pwd

Faire une sauvegarde mysql

mysqldump --defaults-file=~/.my.cnf dolibarr -h localhost -u vince -P 3306 -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | restic -r rest:https://user:pwdmail2.makeitsimple.be:8000/vincent/ backup --stdin --stdin-filename dolibarr.sql

Purger

restic -r /mnt/backup/restic/vincent/ forget --keep-daily 15 --keep-weekly 3 --keep-monthly 6 --keep-yearly 6 --prune

Rest-server

Mettre à jour les dépots APT

apt update

Installer go make & git

apt-get install golang-go git make apache2-utils -y

Télécharger le dépot du rest-server

git clone https://github.com/restic/rest-server

Télécharger les dépendances

go get github.com/restic/rest-server go get github.com/spf13/cobra go get github.com/prometheus/client_golang/prometheus go get github.com/gorilla/handlers go get goji.io/middleware go get golang.org/x/crypto/bcrypt

Entrer dans le dossier, compiler et déployer l'installation

cd rest-server/ CGO_ENABLED=0 go build -o rest-server ./cmd/rest-server cp rest-server /usr/bin

Adapter les droits du dossier de destination

mkdir -p /mnt/backup/restic touch /mnt/backup/restic/.htpasswd chown -R www-data:www-data /mnt/backup/restic

Editer le fichier systemctl rest-server

nano examples/systemd/rest-server.service

Et modifier ExecStart=/usr/local/bin/rest-server –path /mnt/backup/restic –private-repos –append-only

Copier le fichier de démarrage systemctl

cp examples/systemd/rest-server.service /etc/systemd/system/

Générer un utilisateur

htpasswd -B /mnt/backup/restic/.htpasswd **utilisateur**

Activer et lancer le service rest-server

systemctl enable rest-server systemctl start rest-server systemctl status rest-server

Sources

https://www.kloppenborg.net/blog/2019/06/12/restic-backup-server

https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy

https://golb.hplar.ch/2020/04/backup-restic.html

https://www.hostwinds.com/guide/creating-mysql-backups-restic/

https://catlife.drycat.fr/~/XataZ/restic-rempla%C3%A7ant-de-borg-et-duplicati