Need Robocopy Help.

Can someone be so kind as to give me the exact command line for coping files from server A to Sever B?  I need to retain NTFS permissions and log the transfer so that I can make sure everything was copied.
Thank you!
Who is Participating?
Rant32Connect With a Mentor Commented:
ROBOCOPY "\\ServerA\d$\data" "\\ServerB\e$\destination" /E /COPYALL /LOG+:"c:\copy.log"

If you want to delete files from the destination that no longer exist in the source, add the /PURGE option.

Hope this helps.
perplexdConnect With a Mentor Commented:
I'd do it like this:

robocopy "C:\server A Folder" "\\server B\C$\Target Folder" /MIR /SEC /V /NP /LOG:"<local log path>" /R:1 /W:2 /NFL /NDL

I run this as a nightly scheduled task to sync files daily until I am ready to cut over the network name. This lets you poke through the log every day and fix any perms or other errors until you are getting clean nightly copies.

Switches detail:

/MIR /SEC mirrors with ACLs copied. /R /W shortens the default wait time for locked files. This was making my jobs take all night at 30 second wait and 10 retries. /NP shows no progress to get rid of spam in your logs. /NFL /NDL are no file or directlory logging because, again, the successful copies are just spam in your log. So, with all this, your log shows you the errors, or just a summary if there was no error.
Rant32Connect With a Mentor Commented:
Yes, you get the ACL, but /SEC will not copy Owner information. If the Creator Owner group is used in the ACL, the effective permissions may not be the same. /COPYALL will copy ACL, Owner and Audit attributes.

Lowering the retries and waits from the default is a good idea though.

One other note: I also recommend to run the command as a member of the Backup Operators group on the source server.
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

TechnoButtConnect With a Mentor Commented:
As an aside, purely because I"ve hit this recently myself, if your servers are running SMB 2.0 (ie, newer 2008 boxes) and are speaking over Cisco WAAS (ie, replicating files offsite), there is a bug right now that requires code patching oneither the Cisco WAAS or the Microsoft boxes that are both out of band fixes. If this applies, say so, and I'll try to pull the KB article numbers for you.

The reason I mention it, is that NTFS security lookups fail due to the bug, causing robocopy /sec  or robocopy /copyall or similar to fail (despite most file copies ro communications with SMB 2.0 to work fine).  Annoying somewhat rare issue that took me a bit to resolve recently.

This might be a stretch, but I dropped it here in case you run into the issue.
johnnytankiConnect With a Mentor Commented:
Simple usage as below:

net use v: \\serverA\xxx
net use u: \\serverB\yyy
robocopy v:\ u:\ /e /R:2 /W:1 /z /mir >> log.txt

Where V: drive is the source and U: is the destination. It will mirror what is on V to D: which include the NTFS permission. R is the switch for number of Retries on failed copies and W is the Wait time between retries.

User robocopy /??? for more information.
Rant32Connect With a Mentor Commented:
johnnytanki, your command line will certainly not copy file permissions.
perplexdConnect With a Mentor Commented:
Yes, rant32 is correct, MIR alone will definitely not copy permissions. I never cared about owner permissions in the last few runs I had to do, but I am sure he is right about that as well.
Rant32Connect With a Mentor Commented:
Then may I suggest this version, a mix of perplexd's solution and mine?

robocopy "source" "destination" /MIR /COPYALL /NP /LOG:"logfile" /R:1 /W:2 /NFL /NDL

source, destination and logfile can be a local path or UNC path.
/MIR  Copy empty directories and delete files that don't exist in the source (same as /E /PURGE)
/COPYALL  Copy all regular file attributes (RSHA) and security, owner and audit attributes
/NP  No progress
/LOG(+)  Log output to file (use /LOG+: to append to existing file)
/R:1  number of retries
/W:2  Wait time
/NFL  No file list
/NDL  No dir list

I left out /V because it logs skipped files that already exist (spam as well).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.