Automate backup and restore between Bitwarden and/or Vaultwarden vault.
10K+

The goal of this project was to create a backup process of a Bitwarden vault to a self-hosted Vaultwarden instance, ensuring there is always a copy in case the official Bitwarden becomes unavailable.
This docker image automates the backup and restore process for a Bitwarden vault. It provides functionalities for exporting, encrypting, and managing backup versions. Additionally, the script securely deletes outdated files while maintaining a minimum number of recent backups.
โ This script works for Bitwarden as well as Vaultwarden
Source Vault Backup
Destination Vault Cleanup
Destination Vault Restore
The script uses the following environment variables for backup and restore configuration:
Script Config
CRON_SCHEDULE: Your backup cron schedule (Default: 0 0 * * * = every day at 00:00)Authentication
SOURCE_ACCOUNT: Email for the source vault.
SOURCE_PASSWORD: Password for the source vault.
SOURCE_CLIENT_ID: Client ID for the source vault.
SOURCE_CLIENT_SECRET: Client Secret for the source vault.
DEST_ACCOUNT: Email for the destination vault.
DEST_PASSWORD: Password for the destination vault.
DEST_CLIENT_ID: Client ID for the destination vault.
DEST_CLIENT_SECRET: Client Secret for the destination vault.
See prerequisitesโ for how to get Client ID and Client Secret.
Server Configuration
SOURCE_SERVER: URL of the Bitwarden/Vaultwarden server for the source vault.DEST_SERVER: URL of the Bitwarden/Vaultwarden server for the destination vault.Note: You can use both Bitwarden and Vaultwarden for source and destination. If your are using a self-hosted Vaultwarden with a self-signed certificate for the domain see Self-Signed Certificateโ section below.
Security Parameters
ENCRYPTION_PASSWORD: Password used to encrypt and decrypt backup files.File Management
PUID: User ID to set file permissions.PGID: Group ID to set file permissions.ENABLE_PRUNING: If set to false no backups will be pruned. (Default: true)RETENTION_DAYS: Number of days after which outdated files can be deleted. Backup older than this value will be deleted.MIN_FILES: Minimum number of backup files to retain. If all your backups are older than RETENTION_DAYS, keep the minimum files based oh this value.backups/source: Folder for source vault backups.backups/dest: Folder for destination vault backups.Account Settings -> Security -> Keys.services:
bitwarden-portal:
image: reaper0x1/bitwarden-portal:latest
container_name: bitwarden-portal
env_file: .env
volumes:
- your-backups-folder:/app/backups
restart: unless-stopped
your-backups-folder to your backup folder..env file and set the variables. (See .env.example as reference)services:
bitwarden-portal:
image: reaper0x1/bitwarden-portal:latest
container_name: bitwarden-portal
environment:
# Put your cron schedule.
- CRON_SCHEDULE="0 0 * * *"
# Your timezone.
- TZ="Europe/Berlin"
# This is the password used to encrypt and decrypt the backup files.
- ENCRYPTION_PASSWORD="strong-password"
# Your Bitwarden/Vaultwarden SOURCE login info.
- SOURCE_ACCOUNT="[email protected]"
- SOURCE_PASSWORD="source-password"
# You can find these two in Account Settings -> Security -> Keys.
- SOURCE_CLIENT_ID="user.xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
- SOURCE_CLIENT_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Your source server domain/IP.
- SOURCE_SERVER="https://vault.bitwarden.com"
# Your Bitwarden/Vaultwarden DESTINATION login info.
- DEST_ACCOUNT="[email protected]"
- DEST_PASSWORD="dest-password"
# You can find these two in Account Settings -> Security -> Keys.
- DEST_CLIENT_ID="user.xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
- DEST_CLIENT_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Your source server domain/IP.
- DEST_SERVER="http://192.168.1.10:8888" #Can be https://vaultwarden.myserver.local if using self-signed certificate.
# The users belongs to process and files.
- PUID="1000"
- PGID="1000"
# Enable/Disable backups pruning (false/true)
- ENABLE_PRUNING="true"
# Your retention policy for backup files. Backup older than this value will be deleted.
- RETENTION_DAYS=30
# If all your backups are older than RETENTION_DAYS, keep the following minimum files.
- MIN_FILES=10
volumes:
- your-backups-folder:/app/backups
restart: unless-stopped
your-backups-folder to your backup folder.git clone https://github.com/Reaper0x1/bitwarden-portal.git && cd bitwarden-portal
.env file and set the variables. (See .env.example as reference)docker compose up -d
[WIP]
If you are using a local domain with a self-signed certificate for SSL, you need to put your certificate inside the Certs folder.
.crt file inside the certs folder.Content type
Image
Digest
sha256:a1502fa9aโฆ
Size
172.1 MB
Last updated
over 1 year ago
docker pull reaper0x1/bitwarden-portal