Backup remote database with TSQL

  • Hi,

    I want to backup a database on a remote sql server (Server B) with a TSQL script. I've already added a linked server on Server A but I'm not able to execute the backup database command from server A. Is it possible, that I can execute a backup database statement from Server A with backups a database from Server B???

    Thanks for your help in advance!

    Regards,

    Wolfgang

  • What error are you getting? You can run a backup command from just about anywhere (a linked server isn't really necessary), but the real issue is usually one of disk access. The most common error is to run something like:

    backup database x to disk = 'c:\mybackup.bak'

    And the process running the backup doesn't have access to the c: drive or it's to the q: drive and there isn't a q: drive on the server in question.

    backup database x to disk = '\\share_process_has_access_to\mybackup.bak'

    This will work better.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • You will need a linked server in order to backup your database from a remote SQL Server.

    For the purpose of this example lets assume your linked server is named LinkedSQLServer.  You could use the following script to backup a database on the server from your current server as such:

    DECLARE @DynamicSQL NVARCHAR(4000)

    SET @DynamicSQL = 'BACKUP DATABASE MyDatabase TO DISK = ''d:\temp\MyDatabase.bak'''

    EXECUTE LinkedSQLServer.master.dbo.xp_executesql @DynamicSQL

  • Thank you very much! I tried it with the LinkedServer Script and IT WORKS!!!

    Thx for your help!

     

    Regards,

    Wolfgang

  • This was removed by the editor as SPAM

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

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