2

I have two hard drives:

G: is an external USB drive connected to a Windows 10 PC H: is a network drive (another USB drive connected to the USB port of the home network router's USB port)

I have copied all files and sub-folders from G:/my_data_folder onto H:/my_data_folder. Right now, H:/my_data_folder is an exact copy of G:/my_data_folder.

Now I want to create a Robocopy command that I can run periodically on the Win10 PC, that will copy from G: to H:

  • any file/folder in G:/my_data_folder that doesn't already exist in H:/my_data_folder
  • any file in G:/my_data_folder that does already exist in H:/my_data_folder but is a more recent version (ie, has been saved more recently). This newly copied file will over-write the older file on H:.

My understanding of Robocopy is that NOT copying existing files of the same date/time is the default behavior, so I don't need to explicitly exclude them.

I do NOT want H:/my_data_folder to mirror G:/my_data_folder. That is, never erase anything from H:/my_data_folder, even if it is now absent from G:/my_data_folder.

I don't need a log file, but I want to see what it did on screen.

Here's my attempt to compose the appropriate robocopy command:

robocopy g:/my_data_folder h:/my_data_folder /e /np /fft /mt:8 /z /r:5 /w:5

where:

  • /e = copy even empty directories
  • /np = no file copy progress - don't need it
  • /fft = in case of any date/time errors due to network drive
  • /mt:8 = use 8 concurrent threads to speed things up
  • /z = restartable mode so it can recover from an interrupted transfer
  • /r:5 = try maximum 5 restarts
  • /w:5 = wait 5 seconds between restarts

Will this do what I want? Have I missed any critical switches for such a task?

Thanks.

1
  • Regarding /mt:8 I believe 8 is the default. I've bumped this up to 32 and have had really good success with performance. The range is 1-128.
    – HPWD
    Commented Apr 29, 2020 at 21:43

2 Answers 2

3

Your script is perfect as it is.

Just to address the slightly confusing "use /XX just in case" argument made in harrymc's answer:

"To avoid deletions in the target folder, I suggest to add the /XX switch. This is supposed to be the default, but I would add it explicitly just in case."

I recommend against adding redundant switches "just in case". The /XX switch will do nothing in your situation, other than create confusion.

The page cited in the other answer clearly explains what the purpose of that switch is:

"/XX (exclude extra) If used in conjunction with /Purge or /Mir, the exclude extra switch will take precedence and prevent any files being deleted from the destination."

As your script has neither the /MIR nor the /PURGE switches, we can say with 100% certainty that adding /XX "just in case` is redundant.

I've been using Robocopy for years and have pushed around many terabytes of data, all without ever using the /XX switch. Robocopy has never once deleted a single "extra" file.

Further clarification can be seen here.

Just wanted to clear that up!

-1

To avoid deletions in the target folder, I suggest to add the /xx switch. This is supposed to be the default, but I would add it explicitly just in case.

/xx     Excludes extra files and directories.

This switch is further described as:

/XX : eXclude "eXtra" files and dirs (present in destination but not source)
      This will prevent any deletions from the destination. (this is the default)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .