Robocopy

  • Hi

    I'm using Robocopy within a Agent job to copy a backup file to a shared location. It works fine, but, the code for which it exits with is non zero code, so SQL server thinks it has failed when it completes, when it hasn't.

    I've got round this by the following syntax:

    ROBOCOPY D:\filetocopy E:\filetocopyto ^& IF %ERRORLEVEL% LEQ 1 exit 0 /MAXAGE:1

    The problem which I'm having now is that the '/MAXAGE:1' part of the syntax is being ignored when ran, this is important part of the syntax for me but I also need Robocopy to exit with a code 0 when successful! This is so frustrating!

  • Does it work if you change the sequence of the command parameters?

    ROBOCOPY D:\filetocopy E:\filetocopyto /MAXAGE:1 ^& IF %ERRORLEVEL% LEQ 1 exit 0

    If you are putting the above command in a variable before executing this variable: is the defined length of the variable long enough (80 or more characters)?

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
  • Yes, I've tried different sequences, characters (e.g. "", ' ', % etc.) but to avail.

    No, not using variables. If I take either of the options out, it works but not how I want it to work.

Viewing 3 posts - 1 through 2 (of 2 total)

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