feat(restic): Add restic backup maintenance stack

Sets up regular backup maintenance for a restic (S3) backend, and
enables global variables for other roles to use for their individual
backup. Example found in nextcloud role.
This commit is contained in:
Marty Oehme 2025-02-03 18:45:22 +01:00
parent eaeeb4ed6c
commit 135aadf3a0
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
8 changed files with 139 additions and 19 deletions

View file

@ -18,6 +18,10 @@ nextcloud_redis_password: myredispass
nextcloud_db_username: nextcloud
nextcloud_db_password: secretnextcloud
# run restic backups
nextcloud_backup_enable: false
nextcloud_backup_cron: 0 30 3 * * *
nextcloud_php_memory_limit: 5G # maximum ram php may use
nextcloud_php_upload_limit: 15G # maximum size of (web) uploaded files
@ -42,9 +46,3 @@ nextcloud_smtp_from_domain: "{{ server_domain }}"
# nextcloud_s3_ssl: true
# nextcloud_s3_region: eu-central-1
# nextcloud_s3_usepath_style: true
nextcloud_backup_db_enable: false
# nextcloud_backup_db_repo: s3.eu-central-1.wasabisys.com/myrepo
# nextcloud_backup_db_key: <s3-key>
# nextcloud_backup_db_secret: <s3-secret>
# nextcloud_backup_db_timezone: US/Chicago

View file

@ -160,24 +160,22 @@ services:
networks:
- backend
{% if nextcloud_backup_db_enable is not undefined and not false %}
{% if backup_enable is not undefined and not false and nextcloud_backup_enable is not undefined and not false %}
backup:
image: mazzolino/restic
environment:
- "TZ={{ nextcloud_backup_db_timezone }}"
- "TZ={{ restic_timezone }}"
# go-cron starts w seconds
- "BACKUP_CRON=0 30 3 * * *"
- "RESTIC_REPOSITORY={{ nextcloud_backup_db_repo }}"
- "AWS_ACCESS_KEY_ID={{ nextcloud_backup_db_key }}"
- "AWS_SECRET_ACCESS_KEY={{ nextcloud_backup_db_secret }}"
- "RESTIC_PASSWORD={{ nextcloud_backup_db_pass }}"
- "RESTIC_BACKUP_TAGS=nextcloud-db"
- "RESTIC_BACKUP_SOURCES=/mnt/volumes"
- "BACKUP_CRON={{ nextcloud_backup_cron }}"
- "RESTIC_REPOSITORY={{ restic_repo }}"
- "AWS_ACCESS_KEY_ID={{ restic_s3_key }}"
- "AWS_SECRET_ACCESS_KEY={{ restic_s3_secret }}"
- "RESTIC_PASSWORD={{ restic_pass }}"
- "RESTIC_BACKUP_TAGS=nextcloud"
- "RESTIC_BACKUP_SOURCES=/volumes"
volumes:
- db:/mnt/volumes/nextcloud_db:ro
- data:/mnt/volumes/nextcloud_data:ro
networks:
- backend
- db:/volumes/nextcloud_db:ro
- data:/volumes/nextcloud_data:ro
{% endif %}
# metrics: