备份Transaction Log, 遇到了报错.

 

错误截图

备份Transaction Log, 遇到了报错_参考资料

 

错误信息:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Backup failed for Server 'SQL-SPS2013'.  (Microsoft.SqlServer.SmoExtended)

For help, click: ​​http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.2100.60+((SQL11_RTM).120210-1917+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Backup+Server&LinkId=20476​

------------------------------
ADDITIONAL INFORMATION:

System.Data.SqlClient.SqlError: BACKUP LOG cannot be performed because there is no current database backup. (Microsoft.SqlServer.Smo)

For help, click: ​​http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.2100.60+((SQL11_RTM).120210-1917+)&LinkId=20476​

 

原来, 这个错误的原因是从来就没有为该数据库做过full backup, 却仅想要备份log. 解决方案就是先做一个full backup, 然后再备份log就可以了.

假设我们的database的名字是MyTestDB, 可以使用的脚本如下:

BACKUP DATABASE [MyTestDB]
TO DISK = N'C:\MyTestDB.bak'
GO

BACKUP LOG [MyTestDB]
TO DISK = N'C:\MyTestDB.bak'
GO