I have a problem with a robocopy script that is supposed to mirror a directory including the NTFS ACL from one server to another server.
It seems that even though no files have changed, the complete content is copied every time.
This is the command I am using
robocopy \\abc.com\original \\otherserver\mirrordir /XD _MirrorLogs /MIR /COPY:DATS /R:2 /W:2 /LOG+:\abc.com\logfile.LOG /TEE
This is the result (extracts) I am getting
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Wed Jun 12 23:00:19 2013
Source : \\abc.com\original\
Dest : \\otherserver\mirrordir\
Files : *.*
Exc Dirs : _MirrorLogs
Options : *.* /TEE /S /E /DCOPY:DA /COPY:DATS /PURGE /MIR /R:2 /W:2
------------------------------------------------------------------------------
...
2 \\abc.com\original\Best_Practices\
7223 file1.html
194048 file2.doc
3 \\abc.com\original\_history\
155194 file3.xlsm
New File 159091 file4.xlsm
0%
20%
41%
61%
82%
100%
New File 155222 file5.xlsm
0%
21%
42%
63%
84%
100%
...
------------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 422 0 422 0 0 0
Files : 3123 3123 0 0 0 0
Bytes : 649.27 m 649.27 m 0 0 0 0
Times : 0:56:17 0:52:18 0:00:00 0:03:58
Speed : 216918 Bytes/sec.
Speed : 12.412 MegaBytes/min.
Ended : Wed Jun 12 23:56:38 2013
I can understand that when there is the tag "New File" that this needs to be copied. Okay.
What I also understand is that no Dirs are copied according to the summary. This is what I expected.
What I don't understand is that it seems that all files were copied again, even though there were no changes. Most of the files look like file1.html, file2.doc and file3.xlsm, i.e. there is no information why the file is copied (like New File or Newer).
I checked with Beyond Compare if the files are identical, and from the content point of view they are. I thought about different access rights, but then why does the problem not occur in case of the directories (where the access rights were also copied).
Does anyone have a hint for me?
Thanks in advance!
Best Answer
The short answer is that when
robocopy
is copying these folders from one server to another, I suspect that it is seeing the timestamps differently than you expect, so it is deciding that the existing files on the destination are older than the same files on the source. This could be due to differences in the time/timezone/DST settings on the two machines.When
robocopy
analyzes the files before copying, it classifies each file into one of these classes:By default (and with the command line options you have given),
robocopy
will copyLonely
,Newer
, andChanged
files. Files in the other classes will not be copied, and will either be simply reported in the output and/or log, or completly ignored.If
robocopy
is copying a file and overwriting an existing file on the destination, thenrobocopy
thinks that either the timestamo of the source file is before (Newer
) the timestamp of the destination file, or the file sizes are different (Changed
).In order to tell exactly what's happening to each file, you could run
robocopy
with the"/L"
and"/V"
command line options. Using the"/L"
options tellsrobocopy
to not do any actual copying, and only list what would otherwise be copied. Using the"/V"
options tellsrobocopy
to to provide Verbose details.This will show why
robocopy
has decided to copy (and skip) each file. So, for example usingrobocopy
to copy an example fileset.Here is a listing of the files:
In this example, the files named
File1.txt
, are the same size in the source and destination folders, but has aNewer
timestamp inFolder1
. And, the files namedFile2.txt
, have the same timestamp in the source and destination folders, but have different (Changed
) file sizes.Running
robocopy
to copyFolder1
toFolder2
, with the"/L"
and"/V"
command line options looks like this.If you run
robocopy
with the"/L"
and"/V"
command line options on your set of files, it should give you the information of whyrobocopy
is unexpectedly copying these files.I suspect that
robocopy
is seeing the timestamps differently than you expect, and is deciding that the files on the source areNewer
than the same existing files on the destination. This could be due to differences in the time/timezone/DST settings on the two machines.