DataLife Engine / How to migrate Bitwarden and BitBetter to another server

How to migrate Bitwarden and BitBetter to another server


In this article we will migrate our exist Bitwarden and BitBetter services to another server.

Assuming you have already installed the Docker containerization engine with Compose.


To migrate from one self-hosted Bitwarden and BitBetter server to another:

1. Stop your existing Bitwarden server
su bitwarden
cd /opt/bitwarden
./bitwarden.sh stop

2. Make a full copy of the ./bwdata directory of the old server
tar -cpvzf bwdata.tar.gz bwdata

3. Save Bitwarden and BitBetter images to a tar archive
docker image ls
docker save bitbetter/identity > bitbetter-identity.tar
docker save bitbetter/api > bitbetter-api.tar
docker save bitwarden/mssql > bitwarden-mssql.tar
docker save bitwarden/nginx > bitwarden-nginx.tar
docker save bitwarden/events > bitwarden-events.tar
docker save bitwarden/setup > bitwarden-setup.tar
docker save bitwarden/admin > bitwarden-admin.tar
docker save bitwarden/sso > bitwarden-sso.tar
docker save bitwarden/notifications > bitwarden-notifications.tar
docker save bitwarden/icons > bitwarden-icons.tar
docker save bitwarden/attachments > bitwarden-attachments.tar
docker save bitwarden/web > bitwarden-web.tar

4. Create bitwarden user to your new server
adduser bitwarden
passwd bitwarden
usermod -aG docker bitwarden
mkdir /opt/bitwarden
chmod -R 700 /opt/bitwarden
chown -R bitwarden:bitwarden /opt/bitwarden

5. Copy data of the old server to your new server
scp bitwarden.sh bitwarden@your_new_server:/opt/bitwarden/
scp bwdata.tar.gz bitwarden@your_new_server:/opt/bitwarden/
scp bitbetter-*.tar bitwarden@your_new_server:/opt/bitwarden/
scp bitwarden-*.tar bitwarden@your_new_server:/opt/bitwarden/

6. Load Docker images and extract Bitwarden archive on the new server
su bitwarden
cd /opt/bitwarden
docker image load < bitbetter-identity.tar
docker image load < bitbetter-api.tar
docker image load < bitwarden-mssql.tar
docker image load < bitwarden-nginx.tar
docker image load < bitwarden-events.tar
docker image load < bitwarden-setup.tar
docker image load < bitwarden-admin.tar
docker image load < bitwarden-sso.tar
docker image load < bitwarden-notifications.tar
docker image load < bitwarden-icons.tar
docker image load < bitwarden-attachments.tar
docker image load < bitwarden-web.tar
tar -xpvzf bwdata.tar.gz

7. Print the new Bitwarden server's UID
id -u bitwarden

8. Open the file ./bwdata/env/uid.env and check that the listed values match what was printed in the previous step. If they do not match, replace both values with the result of id -u bitwarden.

9. Start your Bitwarden server
./bitwarden.sh start
6-05-2024, 11:30
Вернуться назад