Link to home
Start Free TrialLog in
Avatar of nvill3gas
nvill3gasFlag for United States of America

asked on

RoboCopy behavior

Hello All,

I am struggling with what i thought would be a simple RoboCopy script. However, I am getting some very odd behavior I have never encountered  before and I am at my wits end.  

A bit about the environment the to locations are 2 server 2016 vms and are on the same subnet. Source server is a production file server and destination server test bed for program that a department is considering using. The source location contains sub folders and images mostly with about 55gb of used space. The script is triggered via a scheduled task.

@echo Off
set DirDate=%date:~-10,2%.%date:~-7,2%.%date:~-4,4%
set Name1=IMG_DB_Sync_"%DirDate%"
set Name3=IMG_DB_RoboCopy"%DirDate%"
echo ====%time% - Parameters have been set==== >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
;
echo ====%time% - RoboCopy Starting for Image DataBase Sync==== >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
@echo Off
Robocopy /mir /S /j /R:5 /W:15 /MT:8 "\\Source_Serverr\SharedFolder$\!IMAGE DATABASE" "‪\\Dest_Server\SharedFolder$\!IMAGE DATABASE" /xf ".DS_Store" /LOG:\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name3%.log /v /ts /fp
echo ====%time% - RoboCopy for IMG_DB Sync Finished==== >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
;
@echo Off
echo ====%time% - Sending IMG_DB_Sync_RoboCopy log==== >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
echo ..
powershell.exe -command "& {Send-MailMessage -SmtpServer 'smtp.server.com' -From 'foldersync@domain.com' -To 'IT@domain.com' -Subject 'File Sync' -Body 'Please see attached log for details' -Attachments '\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name3%.log'}"
echo ====%time% - Sent IMG_DB_RoboCopy log file==== >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
;
@echo Off
echo ====%time% - Log Cleanup Starting. ==== >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
ForFiles /p "\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS" /s /d -30 /c "cmd /c del @file & echo @path" >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
echo: >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
echo ====%time% - Log Cleanup Completed. ==== >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
echo ..
;
@echo Off
echo ====%time% - Image DataBase has been synced==== >>\\Source_Server\it_share$\Script_REPO\IMG_DB_Sync\LOGS\%Name1%.log
echo ..
;
End

Open in new window


Now to the meat of my issue. No matter how i run this script or if i just run the robocopy command direct from a cmd window I encounter this issue. When the robocopy job is running it appears to be creating a directory in "C:\Windows\System32\‪" with folder structure of the destination portion of the the command followed by the folder and file structure of the data we are trying to copy. So it reads "C:\Windows\System32\‪\Dest_Server\SharedFolder$\!IMAGE DATABASE"

The issue come into play is when this is happening it is filling the c drive as it is only a 40gb drive for just the OS. Instead of increasing the drive size I would like to see if there a reason\solution for this behavior.

Thanks in advanced for looking at this.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

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
Avatar of nvill3gas

ASKER

Bill,

I just wanted to say thank you for looking at this. I am using all your adjustments you made and its working exactly as I would expect.  I would have never thought to look at the bat file in hex. I'm not sure how or why those three characters ended up in there. Additionally your other tips and pointers are very helpful and will use them moving forward.

Out of curiosity, what editor are you using? I wrote the original bat file in Notepad++.

Again thank you for looking at this.
Avatar of Bill Prew
Bill Prew

My editor of choice (paid product, not free) is Visual Slick Edit.  Has a lot of good features, but the cost has to be considered.  When I pasted your code into Slick Edit, I noticed the funny character (arrow below) and that got me to look at the hex data of the file with a hex viewer.

On the free side I have been using Visual Studio Code lately too, and it is very powerful, still being enhanced, and free.

Notepad++ is a solid free editor as well, but doesn't do as much syntax highlighting as the other two.

User generated image

»bp