1

i try to backup and restore database using sql-server 2008 and got error.

to backup i done this: BACKUP DATABASE MyDB TO DISK='d:\MyDB.BAK' (and its work fine)

to restore i done this: USE MASTER RESTORE DATABASE MyDB FROM DISK='d:\MyDB.BAK

and got this error:

Msg 3159, Level 16, State 1, Line 7
The tail of the log for the database "MyDB " 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.
Msg 3013, Level 16, State 1, Line 7
RESTORE DATABASE is terminating abnormally.

Where I'm wrong ? what is missing ?

thank's in advance

gbn
434k84 gold badges601 silver badges689 bronze badges
asked Nov 19, 2010 at 7:33

1 Answer 1

3

If your MyDB database is in "Full" recovery mode you'll need to do exactly as the message says and back up the log serperately or replace it.

So change your restore command to

RESTORE DATABASE MyDB FROM DISK='d:\MyDB.BAK' WITH REPLACE

If you don't need to be in "Full" recovery mode change to "Simple" and avoid dealing with logs

marc_s
759k185 gold badges1.4k silver badges1.5k bronze badges
answered Nov 19, 2010 at 9:27
Sign up to request clarification or add additional context in comments.

3 Comments

If you post code or XML, please highlight those lines in the text editor and click on the "code" button (101 010) on the editor toolbar to nicely format and syntax highlight it!
thank's for the help, but i got this error: Msg 3101, Level 16, State 1, Line 7 Exclusive access could not be obtained because the database is in use. Msg 3013, Level 16, State 1, Line 7 RESTORE DATABASE is terminating abnormally.
Try running the command from master db. And make sure there are no other sessions. Use the Activity Monitor to check for other sessions

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.