Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Restore database to a remote server Expand / Collapse
Author
Message
Posted Monday, December 17, 2012 4:04 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, October 11, 2013 8:17 AM
Points: 4, 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

Post #1397461
Posted Tuesday, December 18, 2012 10:11 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 5:10 AM
Points: 112, Visits: 1,207
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
Post #1398160
Posted Wednesday, December 19, 2012 9:19 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 8:57 AM
Points: 7,081, Visits: 12,575
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
Post #1398497
Posted Monday, December 24, 2012 8:23 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, October 11, 2013 8:17 AM
Points: 4, 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
Post #1399917
Posted Monday, December 24, 2012 9:59 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 8:57 AM
Points: 7,081, Visits: 12,575
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
Post #1399933
Posted Tuesday, January 1, 2013 11:17 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, May 30, 2014 8:15 AM
Points: 1,056, Visits: 2,687

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



Regards
Durai Nagarajan
Post #1401613
Posted Monday, January 14, 2013 7:01 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, October 11, 2013 8:17 AM
Points: 4, 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.
Post #1407000
Posted Saturday, January 19, 2013 2:23 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, July 17, 2014 12:51 AM
Points: 138, Visits: 661
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
Post #1409239
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse