|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 10:46 AM
Points: 4,
Visits: 19
|
|
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
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Today @ 8:27 PM
Points: 99,
Visits: 1,026
|
|
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
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 1:28 PM
Points: 6,698,
Visits: 11,726
|
|
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
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 10:46 AM
Points: 4,
Visits: 19
|
|
| 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
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 1:28 PM
Points: 6,698,
Visits: 11,726
|
|
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
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 6:32 AM
Points: 847,
Visits: 2,092
|
|
just a doubt, why dont you try log shipping or am i missing something?
Regards Durai Nagarajan
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 10:46 AM
Points: 4,
Visits: 19
|
|
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.
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 1:14 AM
Points: 74,
Visits: 464
|
|
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
|
|
|
|