Background
I've recently updated my Vaultwarden instance in my home lab and wanted yo migrate all the previous data.
Yes, you can export the vault from the UI, but I had several users and don't have access to their accounts, so I needed another way to migrate everything to the new instance.
For context, I run Vaultwarden in an Ubuntu LXC in my Proxmox server. I used tteck's awesome scripts to install it.
Here's how to migrate your Vaultwarden data
1. Backup the original data
- SSH into wherever you have Vaultwarden installed
- Locate the
data
directory. Depending on your Vaultwarden version, thedata
folder can either be in:/opt/vaultwarden/data
/var/lib/vaultwarden/data
- Copy all the contents inside of
data
to a safe directory. I copied them to my local machine usingscp
.
2. Migrate the data to a new Vaultwarden instance
- Install the new Vaultwarden instance
- Stop Vaultwarden
systemctl stop vaultwarden
- Remove the default data dir
sudo rm -r /opt/vaultwarden/data
- Copy the current data over (I used SCP but you can use any file transfer system you like)
- Remove the old RSA keys from the
data
directory. These will be recreated
sudo rm /opt/vaultwarden/data/rsa_key.pem
sudo rm /opt/vaultwarden/data/rsa_key.pub.pem
- Change the directory ownership to vaultwarden
sudo chown -R vaultwarden:vaultwarden /opt/vaultwarden/data
- Restart Vaultwarden
sudo systemctl start vaultwarden
Done!
You should now be able to reach Vaultwarden at the endpoint you've set it up and have all of your old data.
Top comments (3)
Hello,
I am migrating from a docker container that has the sqlite files in the data directory, to the Vaultwarden app on my TrueNAS scale box. This is configured with 2 data directories, data and pgData... I'm starting to realize as I type this that the TrueNAS app is using a Postgres server. Hmm, I'm not a database guy but I can handle a few sql commands; is there an easy way for me to get the sqlite data into PG?
Thanks,
-Bill
Hey Bill!
Though I've never done it, it's been a while since I wanted to get into how to migrate stuff to Postgres, so I did a bit of research and found this:
pgloader.readthedocs.io/en/latest/
Seems that with pgloader you can import or convert a SQLite database into a Postgres one quite easily!
Hey Daniel,
Thanks for looking into that for me! I've actually decided not to migrate. I thought I needed to because of some hosting changes I was making, but it turns out I can leave Vaultwarden right where it is.
Thanks,
-Bill