2021-07-02 16:52:34 +02:00
|
|
|
-- 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.
|
2021-07-14 16:49:10 +02:00
|
|
|
DECLARE @DatabaseNameSafe varchar(100)
|
2021-07-02 16:52:34 +02:00
|
|
|
SET @DatabaseNameSafe = 'vault'
|
|
|
|
|
2017-08-21 16:58:00 +02:00
|
|
|
DECLARE @BackupFile varchar(100)
|
2021-07-02 16:52:34 +02:00
|
|
|
SET @BackupFile = '/etc/bitwarden/mssql/backups/' + @DatabaseNameSafe + '_FULL_$(now).BAK'
|
2017-08-21 16:58:00 +02:00
|
|
|
|
|
|
|
DECLARE @BackupName varchar(100)
|
2021-07-02 16:52:34 +02:00
|
|
|
SET @BackupName = @DatabaseName + ' full backup for $(now)'
|
2017-08-21 16:58:00 +02:00
|
|
|
|
|
|
|
DECLARE @BackupCommand NVARCHAR(1000)
|
2021-07-02 16:52:34 +02:00
|
|
|
SET @BackupCommand = 'BACKUP DATABASE [' + @DatabaseName + '] TO DISK = ''' + @BackupFile + ''' WITH INIT, NAME= ''' + @BackupName + ''', NOSKIP, NOFORMAT'
|
2017-08-21 16:58:00 +02:00
|
|
|
|
|
|
|
EXEC(@BackupCommand)
|