Need Robocopy Help.

Posted on 2010-08-21
Last Modified: 2012-05-10
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!
Question by:victor2008
LVL 12

Accepted Solution

Rant32 earned 250 total points
ID: 33493020
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.

Assisted Solution

perplexd earned 125 total points
ID: 33493045
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.
LVL 12

Assisted Solution

Rant32 earned 250 total points
ID: 33493212
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.

Assisted Solution

TechnoButt earned 63 total points
ID: 33497703
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.
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.


Assisted Solution

johnnytanki earned 62 total points
ID: 33498346
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.
LVL 12

Assisted Solution

Rant32 earned 250 total points
ID: 33498695
johnnytanki, your command line will certainly not copy file permissions.

Assisted Solution

perplexd earned 125 total points
ID: 33501596
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.
LVL 12

Assisted Solution

Rant32 earned 250 total points
ID: 33504547
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).

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now