Solved

MS SQL full restore + transactional log restore

Posted on 2014-02-07
11
658 Views
Last Modified: 2014-02-10
Dear all,

as we do daily SQL 2005 full + transaction log backup, we should do a full restore but leave the DB in non recovery model, then followed by transaction log restore, then change the DB to ready state?

what is the command for that?
0
Comment
Question by:marrowyung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39841707
the first restore is a
RESTORE DATABASE <dbname> FROM <backup_device_specs> WITH NORECOVERY;

next, you can indeed apply log files:
RESTORE LOG <database_name> FROM <backup_device_secps> WITH NORECOVERY;

until you decide to go "online":
RESTORE DATABASE <database_name> WITH RECOVERY;

that's it
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39841931
so can't combine RESTORE LOG <database_name> FROM <backup_device_secps> WITH NORECOVERY;  and RESTORE DATABASE <database_name> WITH RECOVERY; together ?

for example, full DB restore:

RESTORE DATABASE [yyy] FROM  DISK = N'E:\Data\MSSQL\backup\yyy_bak' WITH  FILE = 1,  
MOVE N'BTN905_db' TO N'E:\Data\MSSQL\Data\yyy.mdf',  MOVE N'yyy_log' 
TO N'E:\Data\MSSQL\Data\yyy_1.ldf',  NORECOVERY,  NOUNLOAD,  STATS = 10
GO

Open in new window


and it is in no recovery state. then followed  by the transcation log backup together with online option ?

RESTORE LOG [yyy] FROM  DISK = N'E:\Data\MSSQL\backup\yyy.log' WITH  
FILE = 1,  NOUNLOAD,  STATS = 10
GO

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39842007
sure you can, for the last RESTORE LOG you can do WITH RECOVERY:

RESTORE LOG <database_name> FROM <backup_device_secps> WITH RECOVERY;

for the full technical reference:
http://technet.microsoft.com/en-us/library/ms177446.aspx
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 1

Author Comment

by:marrowyung
ID: 39842076
"sure you can, for the last RESTORE LOG you can do WITH RECOVERY:"

basically I generate that one from SSMS, so I think if I don't do this WITH RECOVERY, it will assume that automatically ?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39842097
the link I gave above has another link:
http://technet.microsoft.com/en-us/library/ms186858.aspx

which clarifies that one, and indeed it's: RECOVERY (the default)
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39846572
so my script is correct I think ?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39846590
yes
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39846591
but should I said I have to restore all Transcation log one by one in order and for any transcation log in between the full restore and the last trans log restore, the transaction log restore can only do non recovery mode?

RESTORE LOG [yyy] FROM  DISK = N'E:\Data\MSSQL\backup\yyy.log' WITH  
FILE = 1,  NORECOVERY, NOUNLOAD,  STATS = 10
GO 

Open in new window


As only the last transcation log restore can remove the NORECOVERY ?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 39846598
exactly. as long as you recover the transactions logs WITH NORECOVERY, you can continue to do so. the only restriction is to restore them in the correct order (sql server will watch and enforce that).
once you restore WITH RECOVERY (explicitely or implicitly by leaving that part of the sql away), you cannot restore any logs to that database, unless you restart a full database restore with norecovery.
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39846654
"sql server will watch and enforce that "

yes, it will prompt for an error if the log is not in order, right?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39846662
yes, exactly
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question