diff --git a/Backing-up-your-vault.md b/Backing-up-your-vault.md index 4b86492..85226dd 100644 --- a/Backing-up-your-vault.md +++ b/Backing-up-your-vault.md @@ -123,4 +123,37 @@ This section contains an index of third-party backup examples. You should review * https://gitlab.com/1O/vaultwarden-backup * https://github.com/jjlin/vaultwarden-backup * https://github.com/jmqm/vaultwarden_backup -* https://github.com/Guru-25/bitwarden-export \ No newline at end of file +* https://github.com/Guru-25/bitwarden-export + + +## Docker-Based Automated Backups (Example) + +If you're using Vaultwarden via Docker and want to automate your backups to a remote machine, the following method might help. It stops the container to ensure consistency, zips the data directory, transfers it via `scp`, and then restarts Vaultwarden. + +**Backup Script Example**: + +```bash +#!/bin/bash +docker-compose down +datestamp=$(date +%m-%d-%Y) +backup_dir="/home//vw-backups" +zip -9 -r "${backup_dir}/${datestamp}.zip" /opt/vw-data* +scp -i ~/.ssh/id_rsa "${backup_dir}/${datestamp}.zip" user@:~/vw-backups/ +docker-compose up -d +```` + +You can automate this via cron: + +```bash +0 0 * * * /root/transfer_vaultwarden_logs.sh +``` + +**Cleanup Script (optional)** to keep only the most recent backup: + +```bash +#!/bin/bash +cd ~/backups || exit +find . -type f -name '*.zip' ! -mtime -1 -exec rm {} + +``` +> Always test restores. To restore, unzip the archive back into `/opt/vw-data`, replacing the previous data directory. +``` \ No newline at end of file