Tuesday, February 5, 2008

Restore Job Fails in SQL Server 2005 with error 3159

Error MesaThe tail of the log for the database "%ls" has not been backed up. Use BACKUP LOG WITH NORECOVERY to back up the log if it contains work that you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log.

Here the scenario was , we were robo copying the database from other server to local drive and restoring the existing database
Step leading for failure:

EXEC master.dbo.xp_restore_database @database='ABCD', @filename = 'E:\MSSQL\Bak\ABCD.sls'

Step replaced to trouble shoot it
EXEC master.dbo.xp_restore_database @database='ABCD', @filename = 'E:\MSSQL\Bak\ABCD.sls'
@with='MOVE "ABCD_DATA" TO "H:\MSSQL\Data\ABCD.mdf"', @with='MOVE "Configuration_LOG" TO "O:\MSSQL\Data\ABCD.ldf"',@with = 'REPLACE'

Explaination: In most cases, under the full or bulk-logged recovery models, SQL Server 2005 requires that you back up the tail of the log to capture the log records that have not yet been backed up. A log backup taken of the tail of the log just before a restore operation is called a tail-log backup.
When you are recovering a database to the point of a failure, the tail-log backup is the last backup of interest in the recovery plan. If you cannot back up the tail of the log, you can recover a database only to the end of the last backup that was created before the failure.
SQL Server 2005 usually requires that you take a tail-log backup before you start to restore a database. The tail-log backup prevents work loss and keeps the log chain intact. However, not all restore scenarios require a tail-log backup. You do not have to have a tail-log backup if the recovery point is included in an earlier log backup, or if you are moving or replacing (overwriting) the database. Also, if the log files are damaged and a tail-log backup cannot be created, you must restore the database without using a tail-log backup. Any transactions committed after the latest log backup are lost

No comments: