Self-hosted Bitwarden has an automated backup feature that’s described in this help document.
However, the document doesn’t give specific details on how to restore the SQL database. Instead it just gives a link to a Microsoft document that provides generic info.
Does anybody have specific instructions on how to restore the SQL database in Docker running under Windows?
Hi robpur, I was working on the same thing today. Here’s what I came up with (on Docker for OS X, though I don’t think that will make a difference). You can find your SA password needed for the commands below in
Use docker and the sqlcmd CLI to restore from a backup like so:
docker exec -it bitwarden-mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YOUR_SA_PASSWORD>' -Q "RESTORE DATABASE vault FROM DISK = '/etc/bitwarden/mssql/backups/vault.bak' WITH REPLACE";
You can also list the files in a backup:
docker exec -it bitwarden-mssql /opt/mssql-tools/bin/sqlcmd -S localhost \
-U SA -P '<YOUR_SA_PASSWORD>' \
-Q 'RESTORE FILELISTONLY FROM DISK = "/etc/bitwarden/mssql/backups/vault_FULL_20190828_235901.BAK"' \
| tr -s ' ' | cut -d ' ' -f 1-2
Or make manual backups (haven’t yet found a way to customise the automated backups):
docker exec -it bitwarden-mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YOUR_SA_PASSWORD>' -Q "BACKUP DATABASE vault TO DISK = '/etc/bitwarden/mssql/backups/vault_backup.bak' WITH STATS=10";
Hope any of this helps!