View Full Version : Robocopy - won't remove extra dirs with /mir

23-11-2010, 09:19 AM

I hope there are some robocopy users here!

I use it to schedule backups from my file server to a FAT32 formatted NAS drive. About 500GB.

I run scheduled incremental backups daily which don't remove extra files/folders on the destination (because then how would I recover an accidentally deleted file?)

I also swap my NAS over once a week so I have an off-site copy, and with a bit of luck secure myself against a corrupted file overwriting a good copy, at least on a week by week basis.

This all works fine. I'm using a free vbs script to run the backup and scheduling using windows scheduled tasks. File server is running Windows server 2003.

Every 5 weeks I alternately mirror my server to one of the drives providing me with 10 weeks of backup in case of accidental loss or deletion, but provides a bit of maintenance on the backups for intended deletion and moved and renamed directories, etc.

But for some reason robocopy cannot remove the directories when mirroring. Only the files. So when it comes time to restore a backup, I have all of these extra, unwanted empty directories.

The vbs script maps the unc path to a network drive for robocopy, but a manual command line test with unc path makes no difference. Robocopy identifies the extra directories, but does not remove them.

They dissappear no problem with rd /s /q \\NAS_UNC

Robocopy switches in the vbs script are:

/V /TEE /S /E /COPY: DAT /PURGE /MIR /R:0 /W:30

I probably don't need /S /E with /MIR, and should change /W:0, but that shouldn't be the problem here based on my manual test:

/V /TEE /MIR /R:0 /W:0

/V /TEE /NOCOPY /PURGE /R:0 /W:0 doesn't work either

Any clues?? I'm stumped.

23-11-2010, 10:33 AM
Generally I have not had any problems with robocopy not deleting folders.

You have /PURGE set which is not necessary.

According to help /S is "Copy sub folders but not empty ones" so it is conceivable that /S is skipping the empty folders, /MIR does not invoke /S, /MIR is the same as /E (copy sub dirs INCLUDING empty ones) and /PURGE.

Also since you have retry set to 0, there is no need to specify a wait time, the wait is between retries, so essentially pointless in your script.

There is no need to add the switch for /COPY: DAT because that is the default anyway.

So basically you have added way too many switches and stuffed it up

Change to this:
/MIR /R:0 /V /TEE

23-11-2010, 10:50 AM
Which is more or less exactly what I had when I did it manually (wait time excepted) and it still didn't work. I appreciate your reply, but not helpful in this instance.

Just tried to do the same with RichCopy (essentially a gui version of robocopy) with the same result. Any other ideas? Worth trying Synctoy? it used to have problems corrupting data on NAS drives, but I understand this was fixed in 2.1?

23-11-2010, 11:01 AM
What version of Windows is it?

When you did your "manual test" did you set up a test folder and test destination? or did you test it on folders that have already failed a deletion?

Also have you tried it with just /MIR and none of the verbose or console stuff?

So just to re-iterate, create a *new* folder structure with files, sync it to a test destination with robocopy /MIR, delete a folder in the source folder, sync again with robocopy /MIR, post back with the result.

24-11-2010, 07:30 AM
Thanks for your reply. OS is Windows Server 2003.

Test was using a test source and test destination, as you suggest.

This morning I ran two more tests:

robocopy testsource(localdrive) testdest(NAS) /mir

Directory tree copies to NAS


robocopy emptysource(localdrive) testdest(NAS) /mir

files deleted but directory tree remains.


robocopy testsource(localdrive) testdest(localdrive) /mir

Directory tree copies to local drive


robocopy emptysource(localdrive) testdest(localdrive) /mir

Entire contents of destination deleted as expected.

So it's a problem with purging directories from the NAS. NAS is formatted FAT32 (requirement for the NAS OS), and the source is NTFS.

Robocopy is run from Admin account.

and FYI when you run robocopy with only /mir you also get the following "default" switches appear in the command window output:

/S /E /COPY: DAT /PURGE /MIR /R:1000000 /W:30