Link to home
Start Free TrialLog in
Avatar of fireguy1125
fireguy1125

asked on

Robocopy Deleting Files at Destination

I'm copy user documents from another company provided on USB drive to the user's home folder in my company.  The user has been creating folders and files in the destination location, but when I run the robocopy job, it deletes all of these files and folders, and replaces them only with what I have on the USB drive.  Please advise which parameters I should change to prevent his from occuring:

robocopy "F:\Documents\User1" "\\fileshare\User\Personal\User1" /MIR /COPY:DATOU /DCOPY:T /R:1 /W:1 /XO /LOG:F:\User1log.txt

Can I just add the /XX parameter, to exclude the extra files? That is what is being logged that there are Extra directories and files.

Do I use in conjunction with the /XO parameter?

Thanks in advance!
Avatar of Bill Prew
Bill Prew

The /MIR is your problem, it is forcing the two folders to be "synced", so extra files are being deleted from the dest.

~bp
Remove /MIR
ROBOCOPY has a lot of important options, make sure you read carefully:

https://technet.microsoft.com/en-us/library/cc733145.aspx

~bp
Avatar of fireguy1125

ASKER

I removed /MIR, but now it's not copying anything.
It seems to be working by using:

robocopy "F:\Documents\User1" "\\fileshare\User\Personal\User1" /MIR /COPY:DATOU /DCOPY:T /R:1 /W:1 /XO /XX /LOG:F:\User1log.txt

I only added the /XX, and folders and files that already existed in the destination were kept intact.

Are there any unforseen issues with using the above command?
I would replace /MIR and /XX with just /E.  Seems more logical.

~bp
Thanks, i'm not following what the difference would be between the two:

robocopy "F:\Documents\User1" "\\fileshare\User\Personal\User1" /MIR /COPY:DATOU /DCOPY:T /R:1 /W:1 /XO /XX /LOG:F:\User1log.txt

robocopy "F:\Documents\User1" "\\fileshare\User\Personal\User1" /E /COPY:DATOU /DCOPY:T /R:1 /W:1 /XO /LOG:F:\User1log.txt
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Bill!
Welcome, glad that helped.

~bp