0

I'm trying to restore a database from a backup.

The BACKUP sqlcmd I'm using is the following

sqlcmd -e -s [SERVERNAME] -q "backup database [DATABASE_NAME] to disk ='[BackupLocation]'"

For the RESTORE, I'm using the following sqlcmd for restore.

sqlcmd -e -s [SERVERNAME] -q "restore database [DATABASENAME] from disk ='[BackUpLocation]"

When i try to restore the database I get this error.

Msg 3159, Level 16, State 1. Server [SERVERNAME], Line 1 The Tail of the log for the database "[DATABASE_NAME]" has note been backed up. Use BACKUP LOG WITH NO RECOVERY or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Server [SERVERNAME], Line 1 RESTORE DATABASE is terminating abnormally.

I'm trying to incorporate the tail log backup but I can't seem to find a way, I keep getting errors like the one below. I already added WITH NORECOVERY at the end of the backup sqlcmd, but had no luck.

Msg 3032, Level 16, State 2, Server [SERVERNAME], Line 1 One or more of the options are not supported for this statement. Review the documentation for supported options.

Does anyone know how can I accomplish this task? Backing up and restoring successful

1 Answer 1

0

You have to backup the log with norecovery to get a tail log backup. So, backup log [yourDatabase] to disk='your log file' with norecovery. Alternatively, if you're just playing around (or are legitimately replacing your database, just add with replace to the restore command.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.