Backup & Restore

  • [font="Tahoma"]create database test

    use test

    create table sampledata

    --populated data into the table sampledata

    --took full and log backup of the same ofcourse with no time gap...did this to demo my friend reg backups(i believe this shudnt be a prob for sql server)

    backup database test to disk='D:\testfullbackup.bak'

    backup log test to disk='D:\testfullbackup.trn'

    --did some dml op...assume i have deleted table sampledata

    restore database test from disk='D:\testfullbackup.bak' with norecovery

    /* I get an error saying :The tail of the log for the database “dbName” has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work 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.

    */

    --as far as my knowledge is concerned there is nothing wrong with the script but still i get --this error...tried googling in vain

    restore log test from disk='D:\testfullbackup.trn'

    --Any help would really be appreciated.

    --Thanks in advance!!![/font]

  • It's more of a warning message, although it shows up as an error. It is warning you that you are about to overwrite the original database name. If you restore to a different DB name you should not receive the error. If you want to restore to the same DB name you have to include the WITH REPLACE or WITH STOPAT as stated in BoL:

    RESTORE LOG

    Beginning with SQL Server 2005, RESTORE LOG can include a file list to allow for creation of files during roll forward. This is used when the log backup contains log records written when a file was added to the database.

    ms186858.note(en-US,SQL.90).gifNote:

    For a database using the full or bulk-logged recovery model, SQL Server 2005 requires in most cases that you back up the tail of the log before restoring the database. Restoring a database without first backing up the tail of the log results in an error, unless the RESTORE statement contains either the WITH REPLACE or WITH STOPAT clause. For more information about tail-log backups, see Tail-Log Backups.

    Shawn Melton
    Twitter: @wsmelton
    Blog: wsmelton.github.com
    Github: wsmelton

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply