Sign-in / Sign-up
Your question

robocopy errorlevel batch file usage.

Tags:
  • Backup
  • Microsoft
  • Windows
Last response: in Windows 2000/NT
March 17, 2005 9:29:45 AM

Archived from groups: microsoft.public.win2000.general (More info?)

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

More about : robocopy errorlevel batch file usage

Anonymous
March 17, 2005 5:32:23 PM

Archived from groups: microsoft.public.win2000.general (More info?)

From: "Jason" <j@jtechservices.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

There are path length limitations.

However, that can be overcome with the SUBST.EXE utility.

Say the path is...

k:\my home\my dir\excel\sunday\october\2002- 2004\

You can use the subbt command such as

subst L: K:\my home\my dir\excel\sunday\october\2002- 2004\

Now you can use "L:" and the path is much shorter.

To disable the drive substitution use...

subst L: /d

This can be easily placed into a .BAT or .CMD batch file.

--
Dave
http://www.claymania.com/removal-trojan-adware.html
http://www.ik-cs.com/ --> "Got a virus?"
March 17, 2005 7:57:01 PM

Archived from groups: microsoft.public.win2000.general (More info?)

would something like this work for you? though this would create a different
log for each day.

@echo off
title PREFORMING BACKUP - PLEASE WAIT. . . .
cls
for /l %%i in (1,1,11) do echo.
echo PREFORMING BACKUP - PLEASE WAIT. . . .
::***THIS SETS THE DATE VARIABLE SO IT CAN BE USED IN A FILE NAME***
setlocal
for /f "tokens=2-4 delims=/ " %%a in (
'date /t'
) do set xdate=%%a-%%b-%%c
::***CAN YOU USE THIS INSTEAD OF ROBOCOPY?***
xcopy [source] [destination] /e /h /o /y
>>D:\utility\backupcommand\log\%xdate%.log
::***CHECKS TO SEE IF THE FILE IS THERE IF NOT SENDS NET SEND MESSAGE***
if not exist D:\utility\backupcommand\log\%xdate%.log net send ***your text***
echo. >>D:\utility\backupcommand\log\%xdate%.log
echo BACKUP WAS DONE ON %date% AT %time:~0,5%
>>D:\utility\backupcommand\log\%xdate%.log
exit

"Jason" wrote:

> 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
>
>
Related resources
Can't find your answer ? Ask !
Anonymous
March 17, 2005 8:49:12 PM

Archived from groups: microsoft.public.win2000.general (More info?)

In addition to the other responses you've received, you need to be aware
that "If ERRORLEVEL 5" actually means "if the error level is greater than
or equal to 5". Thus only two of your IF statements are actually
functional:

if ERRORLEVEL 5 goto send
if not ERRORLEVEL 5 goto log

The first GOTO will be executed if the error level is 5 or greater, the
second if it is 4 or less. Since the label "log" immediately follows the
block of IF statements, the second IF statement and the label can also be
omitted.

Jason <j@jtechservices.com> wrote:
> 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


--
Gary L. Smith gls432@yahoo.com
Columbus, Ohio
Anonymous
March 18, 2005 11:46:23 AM

Archived from groups: microsoft.public.win2000.general (More info?)

"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
March 25, 2005 3:52:25 PM

Archived from groups: microsoft.public.win2000.general (More info?)

what does the :eof stand for?

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

-Jason
Anonymous
March 26, 2005 11:04:13 AM

Archived from groups: microsoft.public.win2000.general (More info?)

"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
...
...
:Exit
October 28, 2009 11:10:01 PM

Try robocopylogscanner.com it should do what you are looking for...