Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Database Restore Stratergy

Author  Topic 

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2013-08-30 : 06:55:38
Dear Experts,
below is the backup strategy in place.
1.Daily Full backup at 2 AM.
2.Log backups every 15 mins.

If i had to restore the database to 5 AM.

I will restore the full backup of 2 AM and then i will restore all the log backups from 2:15 AM to the latest Log backup 5 AM.

is that right what i mentioned?



mohammad.javeed.ahmed@gmail.com

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-08-30 : 08:25:09
That is mostly correct. If your goal is to get the database as it existed at exactly 5:00 AM use point in time recovery rather than relying on the log backup being correct upto 5:00 AM. So I would specify 5:00 AM as the point in time and use log backups including the one from 5:15. This page describes the step by step procedure. http://technet.microsoft.com/en-us/library/ms190982(v=sql.105).aspx

Also be sure to restore WITH NORECOVERY for the full backup and the log files and then do the WITH RECOVERY
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2013-08-30 : 08:59:12
Thank you James.

mohammad.javeed.ahmed@gmail.com
Go to Top of Page

Ifor
Aged Yak Warrior

700 Posts

Posted - 2013-08-30 : 09:23:47
Also, here is an old bit of outline WScript to help generate the RESTORE LOG commands.


var fso = WScript.CreateObject("Scripting.FileSystemObject");

var fldr = fso.GetFolder(".");
var fenum = new Enumerator(fldr.files);
var File_Array = new Array();
var i = 0;

while (!fenum.atEnd())
{
if
(
(fenum.item().Name).toUpperCase().search(/^YourDB/) != -1
&&
(fenum.item().Name).toUpperCase().search(/TRN$/) != -1
)
{
File_Array[i++] = (fenum.item().Path);
}
fenum.moveNext();
}

if (File_Array.length > 0)
{
try
{
var list = fso.createTextFile(".\\RestoreLog.sql", true);

File_Array.sort();

for (i = 0; i < File_Array.length; i++)
{
list.writeLine("RESTORE LOG YourDB FROM DISK = '" + File_Array[i] + "' WITH NORECOVERY;");
list.writeBlankLines(1);
}
}
catch(e)
{
throw(e);
}
finally
{
list.close();
}
}
WScript.Echo("RestoreLog.sql has been generated.");

Go to Top of Page
   

- Advertisement -