SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Restore database to a remote server


Restore database to a remote server

Author
Message
tppromoter
tppromoter
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 22
Hello Everyone,

I am fairly new to this forum and have some experience with SQL. I was recently assigned a project at work and there is some different ideas about how the SQL server agent jobs work. Rather than go on and on about it, is it possible to restore a database from server A onto server B via query that is a step within a job?

I have an SQL job that backs up the database to a shared location and both servers have access to it. I just can't figure out how to get a job that is running on server A to restore the database on server B.


Thanks in advance for the info
prettsons
prettsons
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1883 Visits: 1411
You can do it by two options:

SQL Server Management Studio (GUI)
T-SQL (Command line)

But I only prefer T-SQL because it is easy to use. You can get full idea about all the steps from here: http://www.techrepublic.com/blog/window-on-windows/how-do-i-restore-a-sql-server-database-to-a-new-server/454

SQL Database Recovery Expert :-)
Orlando Colamatteo
Orlando Colamatteo
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40088 Visits: 14413
tppromoter (12/17/2012)
I just can't figure out how to get a job that is running on server A to restore the database on server B.

The restore command has to be executed within the server where the database will be restored. A couple options is you need to start this process from server A and have the database restored on server B:

1. setup server A as a master server and server B as a target server so that a job created on server A will restore a database on server B. Creating a Multiserver Environment (SQL Server 2005)
2. setup a job on server A that executes sqlcmd.exe which then execute a restore command against server B sqlcmd Utility (SQL Server 2005):

sqlcmd.exe -S serverB -E -Q "RESTORE DATABASE [YourDatabase] ...."


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
tppromoter
tppromoter
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 22
Thank you guys for the response. I apologize about the last response. While taking what you have mentioned into consideration, I was able to finally figure the step out that I was missing. I Linked the server B to server A through the management tool. I then created a step in the SQL server agent job on server A that would execute the store procedure in the msdb, invoking my job that was created on server B. This allowed server A to initiate the restore DB job on server B. It works like a charm!!!! thanks for the info
Orlando Colamatteo
Orlando Colamatteo
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40088 Visits: 14413
It may work, just realize that you have given up the notion of centralized management. If the restore fails you will not see it in the log on Server A. Just something to consider if you have many instances in your environment.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
durai nagarajan
durai nagarajan
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3527 Visits: 2784
just a doubt, why dont you try log shipping or am i missing something?

Regards
Durai Nagarajan
tppromoter
tppromoter
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 22
durai nagarajan (1/1/2013)

just a doubt, why dont you try log shipping or am i missing something?



I was considering that, however as per the requirements for this project that was not considered as an option. More important, the database is set to simple restricting the use of the log file.
ffarouqi
ffarouqi
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1126 Visits: 1412
Hi tpprometer.

As per your question "I just can't figure out how to get a job that is running on server A to restore the database on server B.".As mentioned in your post that both servers have access to the shared location (may be on the same domain or shares trust relationship between domains). My question to you is why do you want to set up a job on server A to get your db restored on server B, whereas you can setup a job on server B and take the backup file from the shared path, and restore it on server B?

You kinda of do that in t-sql using network path in your restore script.

Regards,
Faisal

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search