Copy File Across Servers Failing

  • I have 2 servers that are in the same rack, but not on a domain. Ultimately, I want a SQL scheduled job to copy files from Server_A to Server_B

    Logged on to Server_B as Windows\Administrator, I want to copy backup files from Server_A to Server_B with the following SQL Statement:

    DECLARE @cmd varchar(500)

    SET @cmd = 'copy /Y ' + '\\Server_A_IP_Address\f$\Backup\231_StandbyServer\' + 'MyBackupFile.bak ' + 'F:\Backups\231_Server\FULL\'

    EXEC master.dbo.xp_cmdshell @cmd

    which runs this:

    copy /Y \\Server_A_IP_Address\f$\Backup\231_StandbyServer\MyBackupFile.bak F:\Backups\231_Server\FULL\

    I get "access denied"

    But if I put the "[font="Courier New"]copy /Y \\Server_A_IP_Address[/font]...." statement into a DOS command line, it works fine.

    What would prevent the administrator account from running the command in SQL, that runs fine in DOS ?

    Thoughts ?

  • It is running under the SQL Agent service account when you run it in a job. I believe you need to create a proxy

  • homebrew01 (9/16/2013)


    I have 2 servers that are in the same rack, but not on a domain. Ultimately, I want a SQL scheduled job to copy files from Server_A to Server_B

    Logged on to Server_B as Windows\Administrator, I want to copy backup files from Server_A to Server_B with the following SQL Statement:

    DECLARE @cmd varchar(500)

    SET @cmd = 'copy /Y ' + '\\Server_A_IP_Address\f$\Backup\231_StandbyServer\' + 'MyBackupFile.bak ' + 'F:\Backups\231_Server\FULL\'

    EXEC master.dbo.xp_cmdshell @cmd

    which runs this:

    copy /Y \\Server_A_IP_Address\f$\Backup\231_StandbyServer\MyBackupFile.bak F:\Backups\231_Server\FULL\

    I get "access denied"

    But if I put the "[font="Courier New"]copy /Y \\Server_A_IP_Address[/font]...." statement into a DOS command line, it works fine.

    What would prevent the administrator account from running the command in SQL, that runs fine in DOS ?

    Thoughts ?

    When the servers are in a workgroup you will need to create a matching user (username and password) on each server for the account that runs the sql server agent service. The sql server expects to accces the filesystem unchallenged, hence the matching usernames. This is most commonly encountered when setting up log shipping, see my article here[/url] for more info

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • I had not go to the point of running it as a job, just running in a query window, or as DOS command. Does it matter if they are matching Windows accounts, or matching SQL logins ?? I was trying Windows "Administrator" account yesterday, which worked from DOS, but not a SQL query window.

  • Windows accounts. Running from a query window means it is running using the SQL Server Service account.

  • From Server_B, I am not able to pull from Server_A. But if I log on Server_A, I can push to server_B ..... hmmmm

    Well, that's good enough to get what I need done,

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

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