How to migrate vaultwarden
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.
Need a Website or WebApp?
Check out my web development services to get a beautiful, modern website or app for your business.
Here’s how to migrate your Vaultwarden data
1. Backup the original data
- SSH into wherever you have Vaultwarden installed
 - Locate the 
datadirectory. Depending on your Vaultwarden version, thedatafolder can either be in:/opt/vaultwarden/data/var/lib/vaultwarden/data
 - Copy all the contents inside of 
datato 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 
datadirectory. 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.
 Tags: 
    dev  opensource  ubuntu  vaultwarden  bitwarden