Link to home
Start Free TrialLog in
Avatar of GoHuskers
GoHuskersFlag for United States of America

asked on

robocopy advice

I am using robocopy to copy  data and profile folders across the wan to my NAS server so it can be backed up there. It took a little tweaking but it seems to be working OK.
But every day I have to open 10 log files and scroll to the bottom to see if they finished by looking at the summary on the bottom.
my questions are:
is there a way to have it notify me somehow that is has completed or not?
or is there a way to have the log only give me a summary unless there are errors?

here are the scripts I am running thru the task scheduler. Both of theses are in one batch file

robocopy "D:\data" "\\nas\BranchDataBackUp\XXX\data" /S /PURGE /V /XO /NP /LOG:"\\nas\BranchDataBackUp\XXXdata.txt" /B /R:100 /W:15

robocopy "D:\Profiles" "\\nas\BranchDataBackUp\XXX\profiles" /S /PURGE /V /XO /NP /LOG:"\\nas\BranchDataBackUp\XXXprof.txt" /B /R:100 /W:15

what I am try to accomplish is to back up new files and delete non-existing files.

any ideas?

Avatar of eggm4n
eggm4n

I would just write a little batch file and use BLAT to send the mail out:

@echo off
Echo.
Echo -Set Date Variables
Echo.
Set day=%DATE:~7,2%
Set mm=%DATE:~4,2%
Set dd=%DATE:~7,2%
Set yyyy=%DATE:~10,4%

robocopy “\\servername\source” “\\servername\destination” /E /V /LOG+:”d:\logs\robocopy_%mm%%yyyy%.txt” /r:0
if errorlevel 16 echo –Fatal Error– & goto notify
if errorlevel 8 echo –Failed Copies– & goto notify
if errorlevel 4 echo –Mismatches– & goto notify
if errorlevel 2 echo –Extra Files– & goto end
if errorlevel 1 echo –Copy Successful– & goto end
if errorlevel 0 echo –No Changes Found– & goto end

:Notify
c:\blat262\blat -to yourEmail@addy.com -f ServerName@company.com -subject “Problem Report–ReplicationScript.cmd” -bodyF d:\logs\txucopy_%mm%%yyyy%.txt
Goto End

:End
echo.
echo -Done

http://www.blat.net/194/

Avatar of GoHuskers

ASKER

looks promising!!
a few questions before I test it out.
I am setting this up to overwrite the previos so do I need the date variables?
Does this understand UNC to look across the lan where the files are or do I need to map a drive ?
I notice that you are using fewer switches in robocopy than I am. Am I using unnecessary ones?
thanks
That was just an example.  Just plug in your robocopy commands from your post.  You'll need two of these, one for each copy job.
i put a pause at the end of the script to see what I get and this is it
i also changed the goto to notify for no changes found to generate an email so I can run again and again to test

-set date variables
-no changes found
-to does not exist      (this one here I assume is the issue)   and I do not receive an email
-done
press any key to continue...........

i do not get an email
any ideas?
The blat is working well

now to address the rest of the question regarding generating a summary instead of a line by line text file.

how did you come up with the errorlevel syntax? Are these complete or are these an example that I will need to be adjusted?
ASKER CERTIFIED SOLUTION
Avatar of eggm4n
eggm4n

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
your help so far has been incredibly helpful. Your definitly earning your points this time. :-)
thanks i did already fine the error codes and implement them.
but I did receive an error last night but it didn't notify me.
Below is the script that I run and tested.
To test I changed errorlevel 0 to notify then reran the job and it generated an email as expected so the script I believe is working.
the log shows error 21 (0x0000000015).
Is that errorlevel 21 or 15?
Did it not work right or do I need to create an errorlevel 21?
I'm not much of a programmer so any insight would be greatly appreciated.

LOG:
2011/08/30 20:02:43 ERROR 21 (0x00000015) Accessing Source Directory D:\data\
The device is not ready.
ERROR: RETRY LIMIT EXCEEDED.
2011/08/30 20:02:44 ERROR 21 (0x00000015) Accessing Source Directory D:\data\
The device is not ready.

here is my script:
robocopy "D:\data" "\nas-2\BranchDataBackUp\XXX\data" /S /PURGE /V /XO /NP /LOG:"\\nas-2\BranchDataBackUp\XXXdata.txt" /B /R:10 /W:15
if errorlevel 16 echo ***FATAL ERROR*** & goto notify
if errorlevel 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto notify
if errorlevel 14 echo FAIL + MISMATCHES + XTRA & goto notify
if errorlevel 13 echo OKCOPY + FAIL + MISMATCHES & goto notify
if errorlevel 12 echo FAIL + MISMATCHES & goto notify
if errorlevel 11 echo OKCOPY + FAIL + XTRA & goto notify
if errorlevel 10 echo FAIL + XTRA & goto notify
if errorlevel 9 echo OKCOPY + FAIL & goto notify
if errorlevel 8 echo FAIL & goto notify
if errorlevel 7 echo OKCOPY + MISMATCHES + XTRA & goto end
if errorlevel 6 echo MISMATCHES + XTRA & goto end
if errorlevel 5 echo OKCOPY + MISMATCHES & goto end
if errorlevel 4 echo MISMATCHES & goto end
if errorlevel 3 echo OKCOPY + XTRA & goto end
if errorlevel 2 echo XTRA & goto end
if errorlevel 1 echo OKCOPY & goto end
if errorlevel 0 echo No Change & goto end
:Notify
C:\WINDOWS\system32\blat -installt exchange.<name>.com BackUp
C:\WINDOWS\system32\blat \\Nt-nas-2\BranchDataBackUp\XXXdata.txt -subject "XXX data BackUpConcerns" -to sysmon@<domain>.com
Goto End
:End