Home Forums SQL Server 2005 Backups Using Robocopy within SQL Agent job - headache with error codes! RE: Using Robocopy within SQL Agent job - headache with error codes!

  • Thanks for that - it kind of put me on the right track - i think. Although this is what my final solution looks like:

    call c:\robocopy\robocopy c:\Source\ \\SomeShare\Destination\ /NP /MAXAGE:1 /R:1 /PURGE

    IF ERRORLEVEL 16 GOTO LabelErr

    IF ERRORLEVEL 8 GOTO LabelErr

    IF ERRORLEVEL 0 GOTO Label0

    :LabelErr

    SET ERRORLEV=1

    ECHO ERRORLEVEL = %ERRORLEV%

    EXIT 1

    :Label0

    SET ERRORLEV=0

    ECHO %ERRORLEV%

    I then leave the agent job with Process Exit Code of Successful Command as 0. This seems to work OK. Any serious faults such as permission issues cause the SQL agent job to fail (I write out to a log for specific error details) and if the job copies a new file or does nothing if the dest file is as recent as the source, the job reports as successful.

    If any one sees any flaws with this please let me know - for the moment it seems to work how i need it to.

    Thanks

    Doodles