From f3252182988709ade3c418972ca4f7e65f2f5bf6 Mon Sep 17 00:00:00 2001 From: Houfu Ang Date: Tue, 3 Mar 2020 23:06:07 +0800 Subject: [PATCH] Add: Instructions for restoring a nightly backup (#72) --- _articles/hosting/backup-on-premise.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/_articles/hosting/backup-on-premise.md b/_articles/hosting/backup-on-premise.md index c1eaf6e4..0251071c 100644 --- a/_articles/hosting/backup-on-premise.md +++ b/_articles/hosting/backup-on-premise.md @@ -21,4 +21,25 @@ Some particularly important parts of the `./bwdata` directory are: ## Nightly database backups -Bitwarden will automatically take nightly backups of the `mssql` container database. These database backups are kept in the `./bwdata/mssql/backups` directory. Nightly database backups are kept in this directory for 30 days. In the event of data loss, you can restore one of these daily backups. You can read more about SQL Server backup restoration at . +Bitwarden will automatically take nightly backups of the `mssql` container database. These database backups are kept in the `./bwdata/mssql/backups` directory. Nightly database backups are kept in this directory for 30 days. In the event of data loss, you can restore one of these daily backups. + +## Restoring a nightly backup +1. Go to your Bitwarden installation and execute an interactive bash shell on the `bitwarden-mssql` container. + + ``` + docker exec -it bitwarden-mssql /bin/bash + ``` +2. Take note of the backup file you wish to restore in the nightly backups directory. The directory here is a host volume for `./bwdata/mssql/backups`. + ``` + ls /etc/bitwarden/mssql/backups/ + ``` + For this example, the backup we will be using is named `vault_FULL_20200302_235901.BAK`, which is a backup of the vault database on 2 March 2020 at 2359. The full path of the backup in this container would be `/etc/bitwarden/mssql/backups/vault_FULL_20200302_235901.BAK` +3. Execute `sqlcmd` with the required authentication. + ``` + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} + ``` +4. Execute the SQL command `RESTORE DATABASE` with your backup to restore the nightly backup. + ``` + 1> RESTORE DATABASE vault FROM DISK = '/etc/bitwarden/mssql/backups/vault_FULL_20200302_235901.BAK' WITH REPLACE + 2> GO + ```