daknetworks.com

You are here: Blog Robocopy

Robocopy

Windows can't keep copying correct by default. As a note for myself, I'm shamelessly copying from somewhere on the internet:

robocopy source destination /E /ZB /DCOPY:T /COPYALL /R:1 /W:1 /V /TEE /LOG:Robocopy.log

A real-world example is copying the BACKUP-DRIVE to an EXTERNAL-DRIVE but only files for the last 90 days:

robocopy z:\ t:\ /MIR /Z /E /ZB /DCOPY:T /COPYALL /R:1 /W:1 /V /TEE /MAXAGE:90 /LOG:Robocopy.log

Here's what the switches mean:

  • source :: Source Directory (drive:\path or \\server\share\path).
  • destination :: Destination Dir  (drive:\path or \\server\share\path).
  • /E :: copy subdirectories, including Empty ones.
  • /ZB :: use restartable mode; if access denied use Backup mode.
  • /DCOPY:T :: COPY Directory Timestamps.
  • /COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).  Copies the Data, Attributes, Timestamps, Ownser, Permissions and Auditing info
  • /R:n :: number of Retries on failed copies: default is 1 million but I set this to only retry once.
  • /W:n :: Wait time between retries: default is 30 seconds but I set this to 1 second.
  • /V :: produce Verbose output, showing skipped files.
  • /TEE :: output to console window, as well as the log file.
  • /LOG:file :: output status to LOG file (overwrite existing log).

The above will copy the directory. You will have to manually re-setup the share.

This is why the best practice is to use full permission for everyone on the share, and limit the permission using NTFS permissions. And wait till everyone leaves the office.

NOTE: Robocopy can be cantankerous. If you get error message, "access is denied" or "This security ID may not be assigned as the owner of this object" then try it this way.

-first, map a drive: net use k: \\server\share-name /user:pc-name\username password-here

-second, use robocopy with /COPY:DAT instead of /COPYALL. Like this: robocopy E: K:\share-name /E /ZB /DCOPY:T /copy:DAT /R:1 /W:1 /V /TEE /MT:12 /LOG:Robocopy.log

If you need to copy just one file, then try something like:

robocopy D:\path\to\DIRECTORY_NAME K:\DIRECTORY_NAME "file-name-here.ext" /E /Z /ZB /R:5 /W:5 /TBD /V /MT:16

Contact Dak Networks

We are not taking on new clients at this time.