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

Source: Internet
Author: User
Tags filegroup

The following error occurs when you restore a database file group:

 

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.

 

There are two ways to solve this problem:

 

1. Back up the tail log: if the database encounters a problem and you confirm that the tail log has some required information, it is very useful to back up the tail log.

-- Backup primaryfilegroup

Backup database [testfile] filegroup =
N 'Primary'
Disk = n'd: \ primary. Bak'

-- Backupsecondary filegroup

Backup database [testfile] filegroup =
N 'test1'
Disk = n'd: \ secondeary. Bak'

-- Backup log

Backup log [testfile]
Disk = 'd: \ log. trn'

-- Backup taillog

Backup log [testfile]
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. If the log tail cannot be backed up, use the with stopat statement in the restore statement.
Or the with replace clause.

 

-- Backup primaryfilegroup

Backup database [testfile] filegroup =
N 'Primary'
Disk = n'd: \ primary. Bak'

-- Backupsecondary filegroup

Backup database [testfile] filegroup =
N 'test1'
Disk = n'd: \ secondeary. Bak'

-- Backup log

Backup log [testfile]
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

 

For more information, see mssqlserver_3159http: // msdn.microsoft.com/en-us/library/bb283410.aspx.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.