Restore database to a remote server

  • 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

  • This was removed by the editor as SPAM

  • 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

  • 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

  • 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

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

    Regards
    Durai Nagarajan

  • 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.

  • [font="Comic Sans MS"]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[/font]

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply