(I blame Monday!). So can you please tell me if my line of thinking
is in the right direction.
I do daily backups on databases on filegroups, not just the entire
database, since some of my database filegroups are static (change
twice a year) and some are dynamic (change pretty much hourly). Also,
I may or may not have an hourly differential file based on how often
the data changes. I would like to create a routine to restore an
entire database (OldDatabase) with a new name (NewDatabase).
Here is the pseudocode of what I want to have happen (all caps is SQL
code that will append a varchar):
For each filegroup:
BEGIN filegroup loop
RESTORE DATABASE NewDatabase FROM 'OldDatabase File'
WITH NORECOVERY,
MOVE 'Old File Name' TO 'New File Name'
(If a log files is backed up

File Name'
(If a differential file exists

RESTORE DATABASE NewDatabase FROM 'OldDatabase Differential File'
WITH NORECOVERY
(If a differential file exists with a log file

RESTORE DATABASE NewDatabase FROM 'OldDatabase Differential Log
File'
WITH NORECOVERY
END fielgroup loop
After looping through each filegroup I then append the following to
wrap it all up:
RESTORE DATABASE NewDatabase WITH RECOVERY
Would that accomplish what I'm trying to pull off?
Thanks!!!
-Utah
Hi
I'm not sure understood you. Why do you run through filegroups?You should
het a new db with the technique you are using without looping
How many log files fo yo apply ?
1) Restore FULL db
2) Restore last DIFF backup
3) Apply all LOG files backuperd since last DIFF backup
BOL has pretty good examples how to do that
<Utahduck@.hotmail.com> wrote in message
news:1176153244.161025.189040@.q75g2000hsh.googlegr oups.com...
> Okay, for some reason I'm mentally having troubles getting around this
> (I blame Monday!). So can you please tell me if my line of thinking
> is in the right direction.
> I do daily backups on databases on filegroups, not just the entire
> database, since some of my database filegroups are static (change
> twice a year) and some are dynamic (change pretty much hourly). Also,
> I may or may not have an hourly differential file based on how often
> the data changes. I would like to create a routine to restore an
> entire database (OldDatabase) with a new name (NewDatabase).
> Here is the pseudocode of what I want to have happen (all caps is SQL
> code that will append a varchar):
> For each filegroup:
> BEGIN filegroup loop
> RESTORE DATABASE NewDatabase FROM 'OldDatabase File'
> WITH NORECOVERY,
> MOVE 'Old File Name' TO 'New File Name'
> (If a log files is backed up

> File Name'
> (If a differential file exists

> RESTORE DATABASE NewDatabase FROM 'OldDatabase Differential File'
> WITH NORECOVERY
> (If a differential file exists with a log file

> RESTORE DATABASE NewDatabase FROM 'OldDatabase Differential Log
> File'
> WITH NORECOVERY
> END fielgroup loop
> After looping through each filegroup I then append the following to
> wrap it all up:
> RESTORE DATABASE NewDatabase WITH RECOVERY
> Would that accomplish what I'm trying to pull off?
> Thanks!!!
> -Utah
>
No comments:
Post a Comment