Home All Groups Group Topic Archive Search About

robocopy errorlevel batch file usage.

Author
17 Mar 2005 2:29 PM
Jason
I have a robocopy backup I perform daily, and I'm trying to use the
ERRORLEVEL with IF to report any problems with the daily backup. I am
having it call another batch file that will send me a NET SEND
broadcast. I am getting the error, but when I look at my log, it is
showing ERROR 3. I am not asking for any ERROR 3 information in my
batch. Below is how my file's setup. Also, the ERROR 3 is saying that
the 'system cannot find the file specified".  This file has a
ridiculous amount of characters in the name of the file (about 163).
Does robocopy have a limitation on characters in file name??

robocopy d:\directory F:\backup\directory /s /e /TIMFIX /SEC /v /R:5
/W:3 /PURGE >>D:\utility\backupcommand\log\filebackup.log
if ERRORLEVEL 5 goto send
if ERRORLEVEL 6 goto send
if ERRORLEVEL 7 goto send
if ERRORLEVEL 8 goto send
if ERRORLEVEL 9 goto send
if ERRORLEVEL 10 goto send
if ERRORLEVEL 11 goto send
if ERRORLEVEL 12 goto send
if ERRORLEVEL 13 goto send
if ERRORLEVEL 14 goto send
if ERRORLEVEL 15 goto send
if ERRORLEVEL 16 goto send
if not ERRORLEVEL 5 goto log
if not ERRORLEVEL 6 goto log
if not ERRORLEVEL 7 goto log
if not ERRORLEVEL 8 goto log
if not ERRORLEVEL 9 goto log
if not ERRORLEVEL 10 goto log
if not ERRORLEVEL 11 goto log
if not ERRORLEVEL 12 goto log
if not ERRORLEVEL 13 goto log
if not ERRORLEVEL 14 goto log
if not ERRORLEVEL 15 goto log
if not ERRORLEVEL 16 goto log
:log
date /t >> D:\utility\backupcommand\log\filebackup.log
time /t >> D:\utility\backupcommand\log\filebackup.log
echo . >> D:\utility\backupcommand\log\filebackup.log
echo . >> D:\utility\backupcommand\log\filebackup.log
goto end
:send
call send.bat
Show quoteHide quote
:end

Author
17 Mar 2005 9:46 PM
Pegasus (MVP)
Show quote Hide quote
"Jason" <j@jtechservices.com> wrote in message
news:1111069784.945415.60330@f14g2000cwb.googlegroups.com...
> I have a robocopy backup I perform daily, and I'm trying to use the
> ERRORLEVEL with IF to report any problems with the daily backup. I am
> having it call another batch file that will send me a NET SEND
> broadcast. I am getting the error, but when I look at my log, it is
> showing ERROR 3. I am not asking for any ERROR 3 information in my
> batch. Below is how my file's setup. Also, the ERROR 3 is saying that
> the 'system cannot find the file specified".  This file has a
> ridiculous amount of characters in the name of the file (about 163).
> Does robocopy have a limitation on characters in file name??
>
> robocopy d:\directory F:\backup\directory /s /e /TIMFIX /SEC /v /R:5
> /W:3 /PURGE >>D:\utility\backupcommand\log\filebackup.log
> if ERRORLEVEL 5 goto send
> if ERRORLEVEL 6 goto send
> if ERRORLEVEL 7 goto send
> if ERRORLEVEL 8 goto send
> if ERRORLEVEL 9 goto send
> if ERRORLEVEL 10 goto send
> if ERRORLEVEL 11 goto send
> if ERRORLEVEL 12 goto send
> if ERRORLEVEL 13 goto send
> if ERRORLEVEL 14 goto send
> if ERRORLEVEL 15 goto send
> if ERRORLEVEL 16 goto send
> if not ERRORLEVEL 5 goto log
> if not ERRORLEVEL 6 goto log
> if not ERRORLEVEL 7 goto log
> if not ERRORLEVEL 8 goto log
> if not ERRORLEVEL 9 goto log
> if not ERRORLEVEL 10 goto log
> if not ERRORLEVEL 11 goto log
> if not ERRORLEVEL 12 goto log
> if not ERRORLEVEL 13 goto log
> if not ERRORLEVEL 14 goto log
> if not ERRORLEVEL 15 goto log
> if not ERRORLEVEL 16 goto log
> :log
> date /t >> D:\utility\backupcommand\log\filebackup.log
> time /t >> D:\utility\backupcommand\log\filebackup.log
> echo . >> D:\utility\backupcommand\log\filebackup.log
> echo . >> D:\utility\backupcommand\log\filebackup.log
> goto end
> :send
> call send.bat
> :end
>

As a side issue: Your batch file is a little on the chatty side.
It could be condensed to something like this:

robocopy d:\directory F:\backup\directory /s /e /TIMFIX /SEC /v /R:5 /W:3
/PURGE >>D:\utility\backupcommand\log\filebackup.log
if %ErrorLevel% GTR 4 if %ErrorLevel% LSS 17  call send.bat & goto :eof
echo %date% %time% >> D:\utility\backupcommand\log\filebackup.log
echo . >> D:\utility\backupcommand\log\filebackup.log
echo . >> D:\utility\backupcommand\log\filebackup.log
Author
25 Mar 2005 8:52 PM
Jason
what does the :eof stand for?

I don't see another reference in your batch instance..

-Jason
Author
25 Mar 2005 9:04 PM
Pegasus (MVP)
"Jason" <j@jtechservices.com> wrote in message
news:1111783945.073079.267730@z14g2000cwz.googlegroups.com...
> what does the :eof stand for?
>
> I don't see another reference in your batch instance..
>
> -Jason
>

:eof is an inbuilt reference to "End of File". The instuction "goto :eof"
is equivalent to

goto Exit
...
...
Show quoteHide quote
:Exit