Moving 545 Passwords from Bitwarden's Cloud to Vaultwarden: the YubiKey Detour and the Count That Lied
Vicente Louvet
- 8 minutes read - 1596 wordsFor years I kept my password vault in Bitwarden’s cloud on a Premium subscription. It worked, it was cheap, and the clients were lovely. Then Bitwarden’s licensing direction this year gave me the nudge, on top of a reason I’d already settled on: I wanted the vault on hardware I own, behind my own TLS and my own backups.
The clients stay exactly the same. Vaultwarden speaks the Bitwarden API, so the browser extensions, desktop app and phone apps just get a new server URL — the change is where the bytes live, not how I touch them.
What follows is the honest version: a migration designed so my master password never passed through the AI assistant I do my homelab work with, a YubiKey detour of my own making, and three item counts for one vault that disagreed until I learned which to trust.
Why move #
The licensing direction was the nudge, but a modest one — I won’t litigate Bitwarden’s terms beyond “the licensing direction.” The reason was the thing sitting right there all along: I’d already self-hosted my files, my backups, my home automation. Keeping the keys to it all in somebody else’s cloud was the last holdout, and it didn’t take much to fall.
The migration shipped on 2026-10-14. The clients are unchanged, so the hard part was never the front-end — it was moving 545 secrets between servers without leaking the master password, and trusting the numbers that told me it worked.
Deploying it #
The keeper of the vaults is vaultwarden/server:1.37.4, pinned on purpose (web vault 2026.6.0), in Docker on .21. Data lives in a bind-mounted ./data. It sits behind Traefik with the same DNS-01, split-horizon setup and LAN-only wildcard Let’s Encrypt certificate I described in the Home Assistant TLS post. A Pi-hole local DNS record points the vault’s LAN hostname at Traefik. Nothing about it is exposed to the internet.
SIGNUPS_ALLOWED=false went on the moment my account existed. No admin token, no SMTP, no push relay yet — all optional.
The backup is the part I refuse to be cavalier about. A live SQLite database must never be tarballed out from under a running process, so the backup uses the built-in docker exec vaultwarden /vaultwarden backup, which writes a consistent SQLite snapshot with zero downtime. That snapshot gets tarballed together with rsa_key*, attachments/ and sends/; local copies keep 14, the NAS keeps 7, and the existing restic offsite job carries it further away. A RESTORE.txt rides inside every archive so a future-me doesn’t have to remember the procedure. It runs on cron at 03:45 on .21, guarded by flock, with an ntfy push if it fails; the stack lives in my infra-as-code repo.
A migration the assistant could not see #
I do most of my homelab work with an AI assistant in the terminal. For this project that had to stop at a hard line: the master password must never pass through it. So I didn’t ask the assistant to do the migration; I asked it to write tools, and I ran them in my own terminal.
The result is a small set of scripts:
migrate.sh— log in to the cloud withbw, list trash (not exported) and attachments, export a plain JSON to a0600directory, download attachments, log out. Then it pauses while I create the account in the browser, logs in to the new server,bw import bitwardenjson, re-attaches attachments by exact item name, compares counts, closes signups over ssh, and finallyrm -Pthe export.inventory.sh— a sanitised CSV (id, type, name, folder, host, flags, dates; no secrets, no usernames) of whatever serverbwis logged in to. This is the only vault data the assistant ever saw, and it is what the folder plan was built from.apply-folders.sh plan.csv [--execute]— creates folders and moves items. Dry-run by default; that default saved me.
The assistant wrote these without ever seeing a password.
The YubiKey detour #
The cloud account’s 2FA is a YubiKey, and here is where I tripped over my own setup. The bw CLI (2026.9.1) supports YubiKey OTP only. My key is enrolled as FIDO2/WebAuthn — which the CLI can’t do. So the CLI login path never worked, and the --apikey plus bw unlock fallback was a dead end for exactly the same reason.
The fix was to stop fighting it. I exported from the desktop app — a zip of data.json plus an attachments/<cipherId>/file — unpacked it into the layout migrate.sh expected, and ran migrate.sh --skip-export to import, then --finish to re-attach, close signups and shred the export. One attachment. It re-attached fine, by exact item name, and the count matched the plan.
A practical note, since I took the long way to it: organise the new vault before you enable WebAuthn on it. If you mint your WebAuthn credentials first, the CLI is stuck on bw login --apikey from then on, and you’ll be planning migrations around it the way I did.
The count that lied #
Same vault, four answers:
| source | items | folders |
|---|---|---|
| desktop app’s cached view (before export) | 502 | 5 |
| the export file | 545 | 5 |
bw list items right after import | 544 | 6 |
| the server’s SQLite database | 545 ciphers, 1 attachment, 0 in trash | 5 |
The desktop cache was stale by 43 items. The CLI listing after import was off by one item and one folder, and later produced a phantom “Not found.” when I deleted a folder the server never had. Trust the database, not the client caches. When the CLI starts insisting a folder it can’t find exists, bw sync --force clears the phantom.
There’s a trap inside the trap. I wanted a quick count of the live database and reached for sqlite3 "file:db.sqlite3?immutable=1". That uri mode ignores the WAL. SQLite’s write-ahead log holds the committed-but-not-yet-checkpointed transactions, so reading with immutable=1 showed me a stale view: 5 folders and 24 filed items while 24 folders and 108 were already committed.
Count from a snapshot, not the live file. Run /vaultwarden backup, query the db_<timestamp>.sqlite3 it writes, then delete the snapshot — it’s the only read of the database I now trust.
Organising 545 items #
Before any of this, 479 of the 545 items sat in no folder at all; the migration was the moment to fix that.
inventory.sh → a small prefix-to-folder mapping script → plan.csv: 19 folders, 531 items assigned, 13 left for me to file by hand. Biggest buckets: Homelab 117, Dev & Cloud 62, Finance 44 (plus 8 under Taxes), Shopping & Travel 41. Around 12 exact-duplicate pairs were flagged, and deliberately not deleted — flagged and left for a human decision.
The first apply-folders.sh --execute run, on 2026-10-14, died partway: 240 filed, 305 not — and I only found out ten days later. The Mac mini running it had idle-slept mid-run. The rerun is idempotent, which saved me, and it finished on 2026-10-24 with the database showing 20 folders, 531 filed, 14 unfiled, 545 ciphers, and per-folder counts identical to the plan.
Two speedups came out of the rewrite that made the rerun cheap enough to shrug at: one bw list items cached in memory instead of a bw get per item, and base64 instead of bw encode, so each move became one bw edit — about 2 seconds instead of 6. Progress printed every 20 items, run under caffeinate -i. And one bash rule I learned ten days earlier: never edit a bash script while it is running. Bash reads scripts incrementally, so editing a live script is how you get a half-parsed loop doing something you didn’t write.
What is left #
I’m not going to pretend this is done — the cloud account is still alive and I still pay for it. Left on the list:
- re-enable the YubiKey as WebAuthn 2FA on the new server — deliberately postponed, for the reason in the detour section,
- repoint the desktop app, the browser extensions and the phones at the new server,
- and only then cancel Premium and delete the cloud account, once nothing any client points at it anymore.
The migration is verified by the database: 545 ciphers, folders in place. Keeping the old cloud around a little longer is cheap insurance while the clients catch up.
Takeaways #
- Trust the database, not the client caches. Three different views of one vault disagreed by as much as 43 items; the server’s SQLite was the only one that told the truth.
- Count from a snapshot. Reading a live SQLite file with
immutable=1skips the WAL and hands you a stale count./vaultwarden backup, query the snapshot, delete it. - Never route the master password through an AI assistant. The assistant wrote the tools and saw only a sanitised inventory; I ran every command that touched a secret.
- Organise before you enable WebAuthn, or the CLI is stuck on
--apikeyand every future script gets more complicated. - Make the retry idempotent, because your machine will sleep mid-run — more than half of my items were still unfiled for ten days before I noticed, and only idempotency meant the rerun finished cleanly.
- A one-call script beats a per-item loop. Caching the item list and using
base64cut each move from ~6 s to ~2 s. - Never edit a bash script while it is running. Bash reads it incrementally; you will hand it a loop it can’t parse.
545 passwords now live on hardware I own. The clients didn’t change, the cert is real, the backups are consistent, and the one number I trust is the one from the database.