在Debian上恢复SQL Server数据库时,可以采用以下几种方法:
sqlcmd -S localhost -U SA -P [YourPassword]
。RESTORE DATABASE [DatabaseName] FROM DISK = 'PathToBackupFile.bak' WITH FILE = 1, NOUNLOAD, REPLACE, NORECOVERY, STATS = 5
。EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
GO
DECLARE @FilesCmdshell TABLE (outputCmd NVARCHAR (255));
DECLARE @FilesCmdshellCursor CURSOR FOR
SELECT 'RESTORE DATABASE [' + name + '] FROM DISK = N''D:\backup\' + name + '.bak'' WITH FILE = 1, NOUNLOAD, STATS = 10'
FROM sys.databases
WHERE name NOT IN ('master', 'model', 'msdb', 'tempdb', 'distribution');
OPEN @FilesCmdshellCursor;
FETCH NEXT FROM @FilesCmdshellCursor INTO @FilesCmdshellOutputCmd;
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC(@FilesCmdshellOutputCmd);
FETCH NEXT FROM @FilesCmdshellCursor INTO @FilesCmdshellOutputCmd;
END;
CLOSE @FilesCmdshellCursor;
DEALLOCATE @FilesCmdshellCursor;
请注意,在进行数据库恢复操作之前,请确保备份文件完整无损,并且SQL Server实例已启动。恢复操作会覆盖目标数据库,请谨慎操作。建议定期进行备份操作,以防止数据丢失。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: 怎样通过Nginx日志进行故障排查