Msg 3159 The tail of the log for the database "" has not been backedup

还原数据库文件组的时候出现下面的错误:

 

Msg 3159, Level 16, State 1, Line 1
The tail of the log for the database "testfile" has not been backedup. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you donot want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTOREstatement to just overwrite the contents of the log.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

 

解决这个问题有两个方法:

 

1.      备份尾日志:如果数据库遇到问题,并且确定尾部日志有一些需要的信息,这时备份尾部日志非常有用。

--backup primaryfilegroup

backup database [testfile] FILEGROUP= N'PRIMARY' TO  DISK =N'd:\Primary.bak'

--backupsecondary filegroup

backup database [testfile] FILEGROUP= N'test1' TO  DISK =N'd:\secondeary.bak'

--backup log

backup log [testfile]to disk ='d:\log.trn'

--backup taillog

backup log [testfile]to disk ='d:\log1.trn' withnorecovery

 

--restoreprimary filegroup

restore database testfile filegroup='PRIMARY'  from DISK =N'd:\Primary.bak' withnorecovery

--restoresecondary filegroup

restore database testfile filegroup='test1'  from DISK =N'd:\secondeary.bak'withnorecovery

--restore firstlog with norecovery

RESTORE LOG [testfile]FROM  DISK = N'd:\log.trn' WITH FILE = 1, norecovery,  NOUNLOAD,  STATS= 10

--restore taillog with recovery

RESTORE LOG [testfile]FROM  DISK = N'd:\log1.trn' WITH FILE = 1, recovery,  NOUNLOAD,  STATS= 10

 

2.      如果不能备份日志尾部,则使用 RESTORE语句中的WITH STOPAT WITH REPLACE子句。

 

--backup primaryfilegroup

backup database [testfile] FILEGROUP= N'PRIMARY' TO  DISK =N'd:\Primary.bak'

--backupsecondary filegroup

backup database [testfile] FILEGROUP= N'test1' TO  DISK =N'd:\secondeary.bak'

--backup log

backup log [testfile]to disk ='d:\log.trn'

 

--restoreprimary filegroup

restore database testfile filegroup='PRIMARY'  from DISK =N'd:\Primary.bak' withreplace,norecovery

--restoresecondary filegroup

restore database testfile filegroup='test1'  from DISK =N'd:\secondeary.bak'withnorecovery

--restore firstlog with norecovery

RESTORE LOG [testfile]FROM  DISK = N'd:\log.trn' WITH FILE = 1, recovery,  NOUNLOAD,  STATS= 10

 

更多信息参考:MSSQLSERVER_3159http://msdn.microsoft.com/en-us/library/bb283410.aspx

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值