Skip to content

Repository files navigation

Automatically Sync your Password Managers Data to Bitwarden/Vaultwarden

About

BitwardenSync is a docker service that syncs your password manager data to your Bitwarden/Vaultwarden instance.

It watches a directory for export files. For each file it purges the vault through the Bitwarden REST API, verifies the vault is empty, imports the file with the Bitwarden CLI, and removes the file. The import only runs after the server confirms an empty vault, thus repeated imports can never create duplicate entries.

Getting Started

Setup Instructions

  1. Start by duplicating the .env.example file, renaming the duplicate to .env. Fill in the required fields within .env.
  • Supported import formats.
  • BITWARDEN_SYNC_BW_CLIENTID and BITWARDEN_SYNC_BW_CLIENTSECRET come from your account's API key (Web vault -> Settings -> Security -> Keys).
  1. Proceed to craft your docker-compose.yml file, tailoring it to your environment.

Upgrading from 1.x: version 2.0.0 purges the vault through the REST API instead of browser automation. The BITWARDEN_SYNC_BW_OTP_CODE, UID, and GID variables are gone; remove them from your .env and compose file.

Usage

Running the Service

To start the BitwardenSync service, use the following command:

docker-compose up -d --force-recreate

Workflow with BitwardenSync Tool

  1. Configure the BitwardenSync tool to export data into the directory:
/opt/appdata/bitwardensync/data
  1. Once the data file is placed in the above directory, BitwardenSync automatically:
  • Detects the new file and waits until it stops growing. Hidden files and partial uploads (.incomplete, .part, .tmp) are skipped.

  • Purges the existing vault data through the REST API and verifies with the server that the vault is empty. When the purge cannot be verified, the import is aborted and the container exits, thus old and new entries never mix.

  • Imports the new data file into the vault and logs the resulting item count.

  • Deletes the imported file to maintain a clean directory. Files that fail to import move to the .failed/ subdirectory for inspection instead of retrying forever.

  1. The process repeats each time new data is exported into the directory.

Note: SSH keys in Ed25519 format are not supported by Bitwarden. Attempting to use them will result in the error: Failed to execute 'encrypt' on 'SubtleCrypto': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'. For more information, see the Bitwarden SSH Agent documentation.

Standalone Usage

BitwardenSync also works on its own, without an export tool such as BackupOnePass. Place the input file in the directory mentioned above and it processes the data automatically as described.

Development

Install the dev dependencies and run the checks:

bun install          # or: npm install
npm run typecheck    # TypeScript check of the vault tool
npm test             # unit tests (crypto, config, API client, purge logic)
npm run test:e2e     # full loop against a disposable local Vaultwarden (needs docker and the bw CLI)
npm run prettier:check

The container code lives in docker/: entrypoint.sh runs the watch/import loop and src/ holds the TypeScript vault tool (cli.js purge and cli.js count). docker/package.json carries the runtime dependencies; the image builds in two stages and ships only the compiled dist/.

Contributors

We're happy to welcome @Breadfishman's contributions to our work this project. They collaborated closely on the project under our shared account.

Contributing

Please see the contributing guide

Credits

Created by NorkzYT with 💛

► Twitch https://www.twitch.tv/polymathnorkz

► Discord https://discord.com/users/282100214024896522

► GitHub https://github.com/NorkzYT

Click to expand the repo tree

Star history

Star History Chart

About

Automatically Sync your Password Managers Data to Bitwarden/Vaultwarden

Topics

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages