Solved

MS SQL full restore + transactional log restore

Posted on 2014-02-07
11
647 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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 
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

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

735 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