A simple little script that backs up a Bitwarden vault to a local KeePass file.
Project description
Bitwarden to KeePass
A simple little script that backs up a Bitwarden vault to a local KeePass file.
$ bitwarden_to_keepass --keepass-file /path/to/file.kdbx
Installation and Usage
- Install the Bitwarden CLI.
- Install this code.
- Run.
Install the Bitwarden CLI
- Head to the Bitwarden CLI page page and download the native executable for your system.
- Place this file somewhere in your
PATH
. For example, on Linux you might download it to/usr/local/bin
. Make sure that the file is executable (eg:chmod a+x /usr/local/bin/bw
).
For convenience, you can use this command to do all of the above (on Linux)
wget https://github.com/bitwarden/cli/releases/download/v1.22.1/bw-linux-1.22.1.zip \
&& sudo unzip -d /usr/local/bin bw-linux-1.22.1.zip \
&& sudo chmod a+x /usr/local/bin/bw
Install this code
pip install bitwarden-to-keepass
Or see Development.
Run
Run bitwarden_to_keepass
.
You'll be prompted for all the secrets and whatnot. Each secret arg has an
associated env var (see bitwarden_to_keepass --help
for env var names). If
that env var is found, the value from the env var will be used and you will
not be prompted.
You can also send in your secrets via command line, though this is not recommended.
Personally I like to create a secrets.sh
file:
#!/bin/bash
export BW_MASTER_PW=<Bitwarden master password>
export BW_CLIENTID=<Bitwarden API Client ID>
export BW_CLIENTSECRET=<Bitwarden API Client Secret>
# If you also want to backup your Organization data:
export BW_ORG_ID=<Organization ID>
and source it before running:
$ source secrets.sh
$ bitwarden_to_keepass --keepass-file /c/foo/bar.kdbx
Development
Install the Bitwarden CLI and the KeePass CLI as mentioned above.
- Clone the repo:
git clone https://github.com/dougthor42/bitwarden_to_keepass
- Move into that dir:
cd bitwarden-to-keepass
- Create a virtual environment:
python -m venv .venv
- Activate it:
. .venv/bin/activate
- Install python packages:
pip install -U pip setuptools wheel
pip install -e .[dev]
- Run tests to verify:
pytest
- Install pre-commit hooks:
pre-commit install
- Ready to develop
Releasing
-
Update
CHANGELOG.md
by inserting a new heading:--- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Unreleased + +## v1.0.0 (2023-01-14) + + Finally decided to work on this again and got things to decent working state! This should be usable now and ticks all of the original requirements.
-
Update pyproject.toml with the new version:
--- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "bitwarden_to_keepass" -version = "0.0.1" +version = "1.0.0" description = "A simple little script that backs up a Bitwarden vault to a local KeePass file." readme = "README.md" requires-python = ">=3.8"
-
Commit these changes.
-
Create a new git tag
git tag v1.0.0 -m "Release v1.0.0"
.
Then push tags to github. CI will build the source distribution and wheel and upload them to PyPI.
Changelog
See CHANGELOG.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bitwarden_to_keepass-1.0.0.tar.gz
.
File metadata
- Download URL: bitwarden_to_keepass-1.0.0.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c142b187d0b7b5edb379662b3c0c7351022c15001bfa708e86a2b3f02b220304 |
|
MD5 | 3eadf96dbd1b2203290658b2758565eb |
|
BLAKE2b-256 | 883de86a8f05aef2e47d6a0b01d343955d9b5c731dd52fe9b73e7fb95dab6a1b |
File details
Details for the file bitwarden_to_keepass-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: bitwarden_to_keepass-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00ad52f94b9d4875851d5282c5cdd4ec2b242a1814bec135d42e1fa76ade2da6 |
|
MD5 | 8087945eaa16c46093153d1e837a7c8a |
|
BLAKE2b-256 | fd1d79207914ea9a86ca8add2a662475ed79474614d04594cd24a2b5ef53c6a1 |