mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
Allow for changing database name (#1397)
* Remove hard coded database name * Update permissions on build scripts * Update Setup project and run scripts for configuring database name * Remove hyphen from database name flag * Update with suggested changes, still needs testing * Revert SQL statements to concatenantion for testing * Fix typo * Update util/Setup/EnvironmentFileBuilder.cs Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com> * Update SQL commands to prevent SQL injection attacks Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>
This commit is contained in:
@ -1,10 +1,18 @@
|
||||
-- Database name which is set from the backup-db.sh script.
|
||||
DECLARE @DatabaseName varchar(100)
|
||||
SET @DatabaseName = 'vault'
|
||||
|
||||
-- Database name without spaces for saving the backup files.
|
||||
DELCARE @DatabaseNameSafe varchar(100)
|
||||
SET @DatabaseNameSafe = 'vault'
|
||||
|
||||
DECLARE @BackupFile varchar(100)
|
||||
SET @BackupFile = '/etc/bitwarden/mssql/backups/vault_FULL_$(now).BAK'
|
||||
SET @BackupFile = '/etc/bitwarden/mssql/backups/' + @DatabaseNameSafe + '_FULL_$(now).BAK'
|
||||
|
||||
DECLARE @BackupName varchar(100)
|
||||
SET @BackupName = 'vault full backup for $(now)'
|
||||
SET @BackupName = @DatabaseName + ' full backup for $(now)'
|
||||
|
||||
DECLARE @BackupCommand NVARCHAR(1000)
|
||||
SET @BackupCommand = 'BACKUP DATABASE [vault] TO DISK = ''' + @BackupFile + ''' WITH INIT, NAME= ''' + @BackupName + ''', NOSKIP, NOFORMAT'
|
||||
SET @BackupCommand = 'BACKUP DATABASE [' + @DatabaseName + '] TO DISK = ''' + @BackupFile + ''' WITH INIT, NAME= ''' + @BackupName + ''', NOSKIP, NOFORMAT'
|
||||
|
||||
EXEC(@BackupCommand)
|
||||
|
Reference in New Issue
Block a user