Just want the script?
If you don’t want to read the blah blah blah you can access robocopy-script on Github
I want to know the details…
At my day job I was tasked with migrating several websites and folders from one Windows server to another. The sites have a ton of quirky permissions settings because they are mostly intranet sites. Several have anonymous browsing turned off. As you may or may not know if you just copy them via drag and drop in File Explorer you will lose all of those permissions that took years to refine. Additionally you will lose creation dates, etc.
After some research I determined that Robocopy was what I needed to retain all that valuable cruft information. Unfortunately (or fortunately if you dig command line stuff) Robocopy is a command line tool with quite a few flags. A little more digging revealed there is a GUI for Robocopy which allows you to save scripts, but I decided to roll my own script.
Features:
- A simple “config” section in the script where you define the to/from locations
- A config option to run attended or unattended (set this in the script)
- Logging
- Utilization of the following flags (descriptions are verbatim from the Robocopy documentation):
/E
– Copies all subdirectories (including empty ones)./SEC
– Copies NTFS security information. (Source and destination volumes must both be NTFS). Equivalent to /COPY:DATS./COPY:DATSO
– Copies the file information specified by copyflags, which can be any combination of the following : D – file Data. | A – file Attributes | T – file Timestamps. | S – file Security (NTFS ACLs). | O – file Ownership information./V
– Produces verbose output (including skipped files)./TEE
– Displays output in the console window, in addition to directing it to the log file specified by /LOG or /LOG+./NP
– Turns off copy progress indicator (% copied). **/LOG
– Redirects output to the specified file, overwriting the file if it already exists./B
– Copies files in Backup mode (Backup copies are not restartable, but can copy some files that restartable mode cannot). ***/R:10
– Specifies the number of retries on failed copies. (The default is 1 million.)/W:30
– Specifies the wait time between retries. (The default is 30 seconds.)
** I liked seeing the progress as it copied, but all those percentages get written to the log file same as the screen.
*** Consider /Z
to use restartable mode.
Obviously you could tweak the flags in the script to get a combination more suitable for you.
If this sounds like something you might find useful you can access robocopy-script on Github. I should note that this is my first public repo on Github. Yay.