Solved

MS SQL full restore + transactional log restore

Posted on 2014-02-07
11
652 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.

740 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