我从客户端收到一个要求,如果有任何从SQL Server进行数据库备份,默认情况下备份将包含密码。
所以没有人可以在没有密码的情况下恢复数据库。
我建议使用TDE加密解决方案,但他不同意这一点。
任何人都知道,这有什么SQL设置吗?
由于 Nirav
答案 0 :(得分:1)
IDK,如果有任何内置选项(除了TDE )。我们将WinRAR用于类似目的:
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO
DECLARE @fileName varchar(1000)
DECLARE @pathName varchar(1000)
DECLARE @backupName varchar(1000)
DECLARE @backupFullName varchar(1000)
DECLARE @rarName varchar(1000)
DECLARE @compressCommand varchar(1000)
DECLARE @deleteBakCommand varchar(1000)
DECLARE @deleteRarCommand varchar(1000)
DECLARE @moveCommand varchar(1000)
DECLARE @deleteOldRarCommand varchar(1000)
SET @fileName = 'database' + CONVERT(varchar, DATEPART(weekday,getdate()))
set @pathName = 'D:\folder\'
SET @backupName = @fileName + '.bak'
SET @rarName = @fileName + '.rar'
SET @backupFullName =@pathName + @backupName
SET @compressCommand = 'C:\Progra~1\WinRAR\rar a -m5 -pPASSWORD '+ @pathName + @rarName + ' ' + @pathName+@backupName + '"'
SET @deleteBakCommand = 'del ' + @pathName + @backupName
SET @deleteRarCommand = 'del ' + @pathName + @rarName
SET @deleteOldRarCommand = 'del ' + @pathName + 'TARGET\db\' + @rarName
set @moveCommand = 'copy /y ' + @pathName+@rarName + ' ' + @pathName + 'TARGET\db\' + @rarName
EXEC master..xp_cmdshell @deleteBakCommand;
EXEC master..xp_cmdshell @deleteRarCommand;
BACKUP DATABASE DBNAME TO DISK = @backupFullName;
EXEC master..xp_cmdshell @deleteOldRarCommand;
EXEC master..xp_cmdshell @compressCommand;
EXEC master..xp_cmdshell @deleteBakCommand;
EXEC master..xp_cmdshell @moveCommand;
EXEC master..xp_cmdshell @deleteRarCommand;
GO
EXEC sp_configure 'xp_cmdshell', 0