Backup a Database from a remote server

  • Does anyone know how to run a job from server A that will Backup Databases on Server B?

    Appreciate your help

  • Set up a linked server, then

    exec <<linkedserver>>.master.dbo.sp_executesql 'BACKUP DATABASE <<DBName> to disk='\\<<Server>>\e$\<<DBName>.bak''

    Of course, inserting the proper servername and drive/directories.

    /* ----------------------------- */
    Tochter aus Elysium, Wir betreten feuertrunken, Himmlische, dein Heiligtum!

  • You could also use SQLCMD. Just create an operating system job step like this on serverA:

    SQLCMD.exe -E -S serverB -Q "BACKUP DATABSE <databasename> TO DISK = 'c:\databasename.bak'"

  • Edogg (4/9/2010)


    You could also use SQLCMD. Just create an operating system job step like this on serverA:

    SQLCMD.exe -E -S serverB -Q "BACKUP DATABSE <databasename> TO DISK = 'c:\databasename.bak'"

    Actually, that's probably safer than setting up a linked server, which has many inheirent security risks (especially if your not well versed in it).

    /* ----------------------------- */
    Tochter aus Elysium, Wir betreten feuertrunken, Himmlische, dein Heiligtum!

  • Thanks. I decided to use the link server with current security context since we need this to run in a job to make sure we get notified if the job fails.

    Thanks SQL Gurus!!!

  • Alternatively you can create a backup job in the server1 and appropriate notification to operator and the you can invoke the job from any server where sqlcmd is installed

    sqlcmd -S server1-U user-P pwd -Q" exec msdb..sp_start_job 'server1backupjob'" .

    This will backup and will send notification as you want.

Viewing 6 posts - 1 through 5 (of 5 total)

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