DEV Community

Cover image for How to migrate Vaultwarden
Daniel
Daniel

Posted on

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.

Here's how to migrate your Vaultwarden data

1. Backup the original data

  1. SSH into wherever you have Vaultwarden installed
  2. Locate the data directory. Depending on your Vaultwarden version, the data folder can either be in:
    • /opt/vaultwarden/data
    • /var/lib/vaultwarden/data
  3. Copy all the contents inside of data to a safe directory. I copied them to my local machine using scp.

2. Migrate the data to a new Vaultwarden instance

  1. Install the new Vaultwarden instance
  2. Stop Vaultwarden
systemctl stop vaultwarden
Enter fullscreen mode Exit fullscreen mode
  1. Remove the default data dir
sudo rm -r /opt/vaultwarden/data
Enter fullscreen mode Exit fullscreen mode
  1. Copy the current data over (I used SCP but you can use any file transfer system you like)
  2. Remove the old RSA keys from the data directory. These will be recreated
sudo rm /opt/vaultwarden/data/rsa_key.pem
Enter fullscreen mode Exit fullscreen mode
sudo rm /opt/vaultwarden/data/rsa_key.pub.pem
Enter fullscreen mode Exit fullscreen mode
  1. Change the directory ownership to vaultwarden
sudo chown -R vaultwarden:vaultwarden /opt/vaultwarden/data
Enter fullscreen mode Exit fullscreen mode
  1. Restart Vaultwarden
sudo systemctl start vaultwarden
Enter fullscreen mode Exit fullscreen mode

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)

Collapse
 
bill_peters profile image
Bill Peters (Otherbill927)

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

Collapse
 
onticdani profile image
Daniel

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!

Collapse
 
bill_peters profile image
Bill Peters (Otherbill927)

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