copy step of backup job failing using bat file from xp cmdshell

  • Hi,

    I have a backup job that runs two steps.  The first is to backup the database and the second runs a bat file that copies the newly backed up db file to another server.  i can run the bat file successfully from the cmd prompt, however, it fails when running through the sql agent or through mgt. studio.  I get messages like:

    "Network connection could not be found"

    "Multiple connections to a server or shared resource by the same user using more than one user name are not allowed.  Disconnect all previous connections"

    I've disconnected the connections and it doesn't work.  the first step of the bat file is to release the mapped connection and re-map it before doing the copy.  Any ideas?  Thanks.

  • Instead of mapping a drive, try using a UNC (\\ServerName\Directory\[SubDirectory\...]filename).  Be sure that the share permissions are set properly.

  • Thanks for the reply! I tried it both ways and even with the ip address and it still gives the same errors.

  • Are you sure that your destination has been properly shared?

  • I think so because i can run the bat file successfully from the command line; just not mgt studio or through the agent.

  • Hi,

    When you run the job from the command line it's running under the login credentials you used to log into the server.  When the job is run by the Agent it runs under the Agent service account.  Check the Agent account also has access to the share location.

    Cath

  • Thanks for the replies!  I changed the job step to use cmdexec and pointed it to my batch files and it works like a charm.  For some reason; it doesn't work with xp_cmdshell as a transact sql step.  Anyway, thanks again for all of your help!

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

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