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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Database Restore

Author  Topic 

DBA007
Posting Yak Master

145 Posts

Posted - 2009-06-03 : 09:06:54
Dear Friends,
we take a full database backup every end of the day,and differential backup for every 2hours and a transactional log backup for every half an hour,if for suppose my database is not working at 5pm how can I bring it back as working.

jholovacs
Posting Yak Master

163 Posts

Posted - 2009-06-03 : 09:27:15
well, personally I wouldn't bother with the differentials unless it's a large db, but if you're doing a full backup every night it seems like its a manageable size.

ok, it's 5:05, your last transaction log backup happened at 4:45, and something bad happened, time to restore?

first, do a final transaction log backup.
then, restore the last full with the NORECOVERY option
then restore the transaction logs in the order they were created with the NORECOVERY option EXCEPT for the last one.
restore the last transaction log with the RECOVERY option and the STOPAT='<today's date> 17:00:00' where you replace the <today's date> with today's date, obviously.

that should get you where you need to me.

You will need to perform another full backup before you can start backing up differentials and transaction logs again.



SELECT TOP 1
w.[name]
FROM
dbo.women w
INNER JOIN
dbo.inlaws i
ON
i.inlaw_id = w.parent_id
WHERE
i.net_worth > 10000000
AND
i.status IN ('dead', 'dying')
AND
w.husband_id IS NULL
ORDER BY
w.hotness_factor DESC
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-06-03 : 09:31:25
1. restore latest full backup, with norecovery
2. restore all diff backups made after full backup, but before your point-in-time, with norecovery
3. restore all transaction logs after last diff backup, except the last one before your point-in-time, with norecovery
4. restore your last transaction log backup with a point-in-time specification, with recovery

I *think* you can also skip step number 2 completely but then you need to restore all transaction log backups since the full backup. I'm not 100% sure about this though.

Something like this will do I think, but I have never tested it so you may need to revise:

RESTORE DATABASE MyDatabase FROM DISK = 'C:\MyFullBackup.bak' WITH NORECOVERY
RESTORE DATABASE MyDatabase FROM DISK = 'C:\MyDiffBackup1.bak' WITH NORECOVERY
RESTORE DATABASE MyDatabase FROM DISK = 'C:\MyDiffBackup2.bak' WITH NORECOVERY
RESTORE LOG MyDatabase FROM DISK = 'C:\MyLogBackup1.bak' WITH NORECOVERY
RESTORE LOG MyDatabase FROM DISK = 'C:\MyLogBackup2.bak' WITH RECOVERY, STOPAT = '2009-06-03 17:00:00'

EDIT: You need to take one final log backup before doing all this too...

- Lumbago
Go to Top of Page

DBA007
Posting Yak Master

145 Posts

Posted - 2009-06-04 : 07:31:44
Hello Friends,
I think restoring the last Full Backup and the last Differential backup after the Full Backup with NORECOVERY,restoring the Transactional LogBackups after the last Differential Backup is enough,is it necessary to restore all the Differential Backups.
Go to Top of Page

jholovacs
Posting Yak Master

163 Posts

Posted - 2009-06-04 : 08:34:30
no, just the last one.



SELECT TOP 1
w.[name]
FROM
dbo.women w
INNER JOIN
dbo.inlaws i
ON
i.inlaw_id = w.parent_id
WHERE
i.net_worth > 10000000
AND
i.status IN ('dead', 'dying')
AND
w.husband_id IS NULL
ORDER BY
w.hotness_factor DESC
Go to Top of Page

DBA007
Posting Yak Master

145 Posts

Posted - 2009-06-04 : 08:49:27
Dear Friend,
You Mean I have to take the Transaction log Backup when the Database Fails,and restore the last full backup with NORECOVERY and the last Differential Backup with NORECOVERY and restoring the Transactional Logs in a sequence which are taken after the last differential Back and for the last Transaction log I have to specify WITH RECOVERY by Specifying the time,AM I right.
Go to Top of Page
   

- Advertisement -