1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-11 15:17:44 +01:00
bitwarden-server/util/MsSql/backup-db.sql
2017-08-21 10:58:00 -04:00

14 lines
552 B
Transact-SQL

DECLARE @TheDate NVARCHAR(20)
SET @TheDate = REPLACE(CONVERT(VARCHAR, GETDATE(),101),'/','') + '_' + REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')
DECLARE @BackupFile varchar(100)
SET @BackupFile = '/etc/bitwarden/mssql/backups/vault_FULL_'+ @TheDate + '.BAK'
DECLARE @BackupName varchar(100)
SET @BackupName = 'vault full backup for '+ @TheDate
DECLARE @BackupCommand NVARCHAR(1000)
SET @BackupCommand = 'BACKUP DATABASE [vault] TO DISK = ''' + @BackupFile + ''' WITH INIT, NAME= ''' + @BackupName + ''', NOSKIP, NOFORMAT'
EXEC(@BackupCommand)