From 9420f6875e9b186a6c6b74204b427ff8516d19cf Mon Sep 17 00:00:00 2001 From: root Date: Sat, 20 Jan 2024 21:02:38 +0100 Subject: [PATCH] add restic config --- .gitignore | 2 + backups/.autorestic.yaml | 81 ++++++++++++++++++++++++++++ backups/autorestic.service | 10 ++++ backups/autorestic.timer | 9 ++++ backup_db.sh => backups/backup_db.sh | 2 +- 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 backups/.autorestic.yaml create mode 100644 backups/autorestic.service create mode 100644 backups/autorestic.timer rename backup_db.sh => backups/backup_db.sh (97%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07c13cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.autorestic.env +.autorestic.lock.yml diff --git a/backups/.autorestic.yaml b/backups/.autorestic.yaml new file mode 100644 index 0000000..d740a5a --- /dev/null +++ b/backups/.autorestic.yaml @@ -0,0 +1,81 @@ +version: 2 + + +global: + forget: + keep-hourly: 24 + keep-daily: 7 + keep-weekly: 4 + keep-monthly: 12 + +backends: + fch: + type: sftp + path: FCH_serveur:backups/ + +locations: + nextcloud_data: + from: + - /var/lib/docker/volumes/docker_nextcloud + to: + - fch + cron: 0 0 * * * + forget: prune + + + nextcloud_conf: + from: + - /var/lib/docker/volumes/docker_nextcloud-conf + to: + - fch + cron: 0 0 * * * + forget: prune + + nextcloud_data: + from: + - /var/lib/docker/volumes/docker_nextcloud + to: + - fch + cron: 0 0 * * * + forget: prune + + nextcloud_db: + from: + - /DATA/dump_bdd/nextcloud-db + to: + - fch + cron: 0 0 * * * + forget: prune + hooks: + before: + - /DATA/docker/services/backups/backup_db.sh nextcloud-db postgresql + + onlyoffice: + from: + - /var/lib/docker/volumes/docker_onlyoffice-cache + - /var/lib/docker/volumes/docker_onlyoffice-data + to: + - fch + cron: 0 0 * * * + forget: prune + + traefik-certs: + from: + - /DATA/docker/services/certs + to: + - fch + cron: 0 0 * * * + forget: prune + + repos: + from: + - /DATA/docker/services/ + to: + - fch + options: + backup: + exclude: + - '.git' + cron: 0 0 * * * + forget: prune + diff --git a/backups/autorestic.service b/backups/autorestic.service new file mode 100644 index 0000000..17c3108 --- /dev/null +++ b/backups/autorestic.service @@ -0,0 +1,10 @@ +[Unit] +Description=Backups yay + +[Service] +Type=oneshot +ExecStart=autorestic -c /DATA/docker/services/backups/.autorestic.yml --ci cron +# fail if backup takes more than 1 day +TimeoutStartSec=86400 +IPAccounting=yes +MemoryAccounting=yes diff --git a/backups/autorestic.timer b/backups/autorestic.timer new file mode 100644 index 0000000..dcfcc06 --- /dev/null +++ b/backups/autorestic.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Backups yay + +[Timer] +# Trigger every 10 minutes +OnCalendar=*:0/10:0 + +[Install] +WantedBy=timers.target diff --git a/backup_db.sh b/backups/backup_db.sh similarity index 97% rename from backup_db.sh rename to backups/backup_db.sh index 8e5116a..26462ea 100755 --- a/backup_db.sh +++ b/backups/backup_db.sh @@ -4,7 +4,7 @@ # # exports the database of a running docker container in a dump in $BACKUP_DIR/$CONTAINER_NAME/ -BACKUP_DIR=/DATA/BACKUP/dbdumps +BACKUP_DIR=/DATA/dump_bdd/ # Check container existence