Skip to content

Commit

Permalink
feat: Add vaultwarden to backups
Browse files Browse the repository at this point in the history
  • Loading branch information
fezu54 authored and Fabian Finke committed Dec 30, 2024
1 parent 40707d4 commit 0bd7d39
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
db.env
.idea
2 changes: 1 addition & 1 deletion backup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN unzip -j rclone-${RCLONE_VERSION}-linux-amd64.zip
RUN chmod 0700 simplepush.sh
RUN chmod 0700 rclone

FROM b3vis/borgmatic:${BORGMATIC_VERSION}
FROM ghcr.io/borgmatic-collective/borgmatic:${BORGMATIC_VERSION}
COPY --from=builder simplepush.sh /usr/local/bin/
COPY --from=builder rclone /usr/local/bin/
RUN apk add openssl
81 changes: 36 additions & 45 deletions backup/borgmatic.d/config.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,37 @@
location:
source_directories:
- /mnt/source
repositories:
- /mnt/borg-repository
one_file_system: true

storage:
compression: lz4
archive_name_format: 'backup-{now}'

retention:
keep_hourly: 2
keep_daily: 7
keep_weekly: 4
keep_monthly: 12
keep_yearly: 10
prefix: 'backup-'

consistency:
checks:
- repository
- archives
check_last: 3
prefix: 'backup-'

hooks:
before_backup:
- echo "Starting a backup job..."
after_backup:
- echo "Backup created..."
after_actions:
- echo "Uploading backup..."
- rclone sync /mnt/borg-repository nextcloud:nextcloud-backup -P --dry-run
- rclone sync /mnt/borg-repository nextcloud:nextcloud-backup -v
- simplepush.sh -t "Backup done" -m "Creation and uploading of backup successful"
on_error:
- echo "Error while creating a backup."
- simplepush.sh -t "Error creating backup" -m "Creation of backup failed. Check borgmatic logs."
mysql_databases:
- name: all
hostname: db
port: 3306
username: root
#options: "--single-transaction"
source_directories:
- /mnt/source
- /mnt/vaultwarden/attachments
repositories:
- /mnt/borg-repository
one_file_system: true
archive_name_format: 'backup-{now}'
keep_hourly: 2
keep_daily: 7
keep_weekly: 4
keep_monthly: 12
keep_yearly: 10
checks:
- repository
- archives
check_last: 3
before_backup:
- echo "Starting a backup job..."
after_backup:
- echo "Backup created..."
after_actions:
- echo "Uploading backup..."
- rclone sync /mnt/borg-repository nextcloud:nextcloud-backup -P --dry-run
- rclone sync /mnt/borg-repository nextcloud:nextcloud-backup -v
- simplepush.sh -t "Backup done" -m "Creation and uploading of backup successful"
on_error:
- echo "Error while creating a backup."
- simplepush.sh -t "Error creating backup" -m "Creation of backup failed. Check borgmatic logs."
mariadb_databases:
- name: all
hostname: db
port: 3306
username: root
sqlite_databases:
- name: vaultwarden
path: /mnt/vaultwarden/db.sqlite3

4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ services:
- LETSENCRYPT_HOST=${VAULTWARDEN_PREFIX}.${DNS_ADDRESS}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
networks:
- default
- proxy-tier
- backups
env_file:
- db.env

borgmatic_backup:
build:
Expand All @@ -69,6 +66,7 @@ services:
RCLONE_VERSION: v1.68.2
volumes:
- nextcloud:/mnt/source:ro
- vaultwarden:/mnt/vaultwarden:ro
- ${VOLUME_TARGET}:/mnt/borg-repository
- ./backup/borgmatic.d:/etc/borgmatic.d
- borg-config:/root/.config/borg
Expand Down

0 comments on commit 0bd7d39

Please sign in to comment.