dbTalk Databases Forums  

t-sql restore

microsoft.public.sqlserver.setup microsoft.public.sqlserver.setup


Discuss t-sql restore in the microsoft.public.sqlserver.setup forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Joe
 
Posts: n/a

Default t-sql restore - 05-07-2004 , 09:37 AM






Hi all-
I have a DB that I'm backing up nightly, and I need to restore it into a
"holding" DB so I can run DTS on it.

I know I can do a basic restore in t-sql, but can I use the "move" attribute
to restore as another DB?

Would this work:
BACKUP DATABASE dbLive TO dbLiveDaily WITH init <- backs up DB and
overwrites the existing backup
BACKUP LOG dbLive TO dbLiveLogDaily WITH init <- backs up logs and
overwrites the existing backup
RESTORE DATABASE dbLive FROM dbLiveDaily,
MOVE 'dbLive' TO 'e:\dbLiveHolding\data\dbLiveHolding.mdf',
MOVE 'dbLiveLog' TO 'e:\dbLiveHolding\log\dbLiveLog.ldf'

Thanks in advance!!

Best Regards,
Joe



Reply With Quote
  #2  
Old   
Hari Prasad
 
Posts: n/a

Default Re: t-sql restore - 05-07-2004 , 10:07 AM






Hi,

Using the Move option you can restore the database backup with a different
name in the same SQL Server.
Say you are backing up the database dbLive , now you need to restore the
backup to a new database named "DBOFFLINE"
Issue the below command with NORECOVERY, so as you can restore the
transaction log backup as well)
Your command had some syntax issues, so use the below

1. RESTORE DATABASE dboffline FROM dbLiveDaily
WITH MOVE 'dbLive' TO 'e:\dbLiveHolding\data\dbLiveHolding_offline.mdf',
MOVE 'dbLiveLog' TO 'e:\dbLiveHolding\log\dbLiveLog_offline.ldf' ,
NORECOVERY

2. RESTORE Log dboffline FROM dbLiveLogDaily WITH RECOVERY


Note:
It is not required to put INIT in the below command as you specified.

BACKUP LOG dbLive TO dbLiveLogDaily WITH init

Thanks
Hari
MCDBA


"Joe" <anon (AT) ymous (DOT) com> wrote

Quote:
Hi all-
I have a DB that I'm backing up nightly, and I need to restore it into a
"holding" DB so I can run DTS on it.

I know I can do a basic restore in t-sql, but can I use the "move"
attribute
to restore as another DB?

Would this work:
BACKUP DATABASE dbLive TO dbLiveDaily WITH init <- backs up DB and
overwrites the existing backup
BACKUP LOG dbLive TO dbLiveLogDaily WITH init <- backs up logs and
overwrites the existing backup
RESTORE DATABASE dbLive FROM dbLiveDaily,
MOVE 'dbLive' TO 'e:\dbLiveHolding\data\dbLiveHolding.mdf',
MOVE 'dbLiveLog' TO 'e:\dbLiveHolding\log\dbLiveLog.ldf'

Thanks in advance!!

Best Regards,
Joe





Reply With Quote
  #3  
Old   
Joe
 
Posts: n/a

Default Re: t-sql restore - 05-07-2004 , 10:20 AM



Thanks Hari!


"Hari Prasad" <> wrote

Quote:
Hi,

Using the Move option you can restore the database backup with a different
name in the same SQL Server.
Say you are backing up the database dbLive , now you need to restore the
backup to a new database named "DBOFFLINE"
Issue the below command with NORECOVERY, so as you can restore the
transaction log backup as well)
Your command had some syntax issues, so use the below

1. RESTORE DATABASE dboffline FROM dbLiveDaily
WITH MOVE 'dbLive' TO
'e:\dbLiveHolding\data\dbLiveHolding_offline.mdf',
MOVE 'dbLiveLog' TO 'e:\dbLiveHolding\log\dbLiveLog_offline.ldf' ,
NORECOVERY

2. RESTORE Log dboffline FROM dbLiveLogDaily WITH RECOVERY


Note:
It is not required to put INIT in the below command as you specified.

BACKUP LOG dbLive TO dbLiveLogDaily WITH init

Thanks
Hari
MCDBA


"Joe" <anon (AT) ymous (DOT) com> wrote in message
news:OqNJHCENEHA.3096 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Hi all-
I have a DB that I'm backing up nightly, and I need to restore it into a
"holding" DB so I can run DTS on it.

I know I can do a basic restore in t-sql, but can I use the "move"
attribute
to restore as another DB?

Would this work:
BACKUP DATABASE dbLive TO dbLiveDaily WITH init <- backs up DB and
overwrites the existing backup
BACKUP LOG dbLive TO dbLiveLogDaily WITH init <- backs up logs and
overwrites the existing backup
RESTORE DATABASE dbLive FROM dbLiveDaily,
MOVE 'dbLive' TO 'e:\dbLiveHolding\data\dbLiveHolding.mdf',
MOVE 'dbLiveLog' TO 'e:\dbLiveHolding\log\dbLiveLog.ldf'

Thanks in advance!!

Best Regards,
Joe







Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.