?
Solved

MS SQL full restore + transactional log restore

Posted on 2014-02-07
11
Medium Priority
?
685 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
  • 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

839 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