docs(readme): specific docker backup instructions

Rudra Singh 2025-07-06 16:40:25 -04:00
parent ebb41ec32e
commit 2dc903bf7e

@ -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
* 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/<user>/vw-backups"
zip -9 -r "${backup_dir}/${datestamp}.zip" /opt/vw-data*
scp -i ~/.ssh/id_rsa "${backup_dir}/${datestamp}.zip" user@<REMOTE_IP>:~/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.
```