Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restoring specific MSSQL .bak file? #651

Closed
perfecto25 opened this issue Feb 4, 2020 · 2 comments
Closed

restoring specific MSSQL .bak file? #651

perfecto25 opened this issue Feb 4, 2020 · 2 comments

Comments

@perfecto25
Copy link

Hello, is it possible to restore a specific time-stamped .BAK file?

Im running BW on Centos 7, using docker, dont have any MSSQL tools installed, and was hoping there was an easier way to restore a .BAK than going via MSSQL docker container, didnt find any documentation on doing this.

@kspearrin
Copy link
Member

You could use sqlcmd inside of the mssql container or expose the mssql container to the host and connect with a sql server tool like SSMS.

@perfecto25
Copy link
Author

perfecto25 commented Feb 4, 2020

Thank you, the restore process was fairly quick, leaving these instructions for anyone that may run into this,

To restore MSSQL database .BAK file

  1. get the SA password
bw_host> cat bwdata/env/mssql.override.env 
SA_PASSWORD=<your password>

copy BAK file to the container,

bw_host>  docker cp /etc/bitwarden/bwdata/mssql/backups/vault_FULL_20191209_235901.BAK  bitwarden-mssql:/tmp

login into the container,

bw_host>  docker exec -ti bitwarden-mssql bash

check if your BAK file is inside the container,

root@container> ls /tmp 

Login to MSSQL command line,

root@container:/# /opt/mssql-tools/bin/sqlcmd -S localhost -U SA
## provide SA_PASSWORD

Restore the Database ,

1> ALTER DATABASE vault SET SINGLE_USER
2> WITH ROLLBACK IMMEDIATE
3> GO
Nonqualified transactions are being rolled back. Estimated rollback completion: 0%.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
1> RESTORE DATABASE vault FROM DISK='/tmp/vault_FULL_20200125_235901.BAK' WITH REPLACE
2> GO
Processed 912 pages for database 'vault', file 'vault' on file 1.
Processed 4 pages for database 'vault', file 'vault_log' on file 1.
RESTORE DATABASE successfully processed 916 pages in 2.383 seconds (3.001 MB/sec).

exit the container, BW should pick up changes in few minutes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants