0

I have multiple drives, where I want to sync to another drive with robocopy. The following structure:

E:\
 - ServerFolders
 -- A
 -- B

F:\
 - ServerFolders
 -- C
 -- D

This is the command I used:

robocopy E: G: /e /zb /np /copy:DAT /dcopy:T /r:2 /w:5 /mir /log+:"C:\Users\Administrator\Desktop\logs\backup_%date%.log" /XD "System Volume Information" "Recycler"
robocopy F: G: /e /zb /np /copy:DAT /dcopy:T /r:2 /w:5 /mir /log+:"C:\Users\Administrator\Desktop\logs\backup_%date%.log" /XD "System Volume Information" "Recycler"

As you can see I make two calles and want preserve all timestamps. If something is deleted from E: or F: it should also get deleted on G:.

The result now is that if the backup finished, everything from E: isn't available anymore. I think that is because of /mir, which deletes folders that doesn't exist anymore. What I want is the following:

G:\
 - ServerFolders
 -- A
 -- B
 -- C
 -- D

What do I have to change for that? If I specify the subfolders ServerFolders the same problem will occur. Additionally, I have to change the script every time a new folder is added.

Edit:

The only thing which comes to my mind is to do this per each folder:

set source1=%fromHDD1%\ServerFolders\A
set source2=%fromHDD1%\ServerFolders\B
set source3=%fromHDD2%\ServerFolders\C
set target1=%to%\ServerFolders\A
set target2=%to%\ServerFolders\B
set target3=%to%\ServerFolders\C

robocopy %source1% %target1% /e /zb /np /copy:DAT /dcopy:T /r:2 /w:5 /mir /XD "System Volume Information" "Recycler"
robocopy %source2% %target2% /e /zb /np /copy:DAT /dcopy:T /r:2 /w:5 /mir /XD "System Volume Information" "Recycler"
robocopy %source3% %target3% /e /zb /np /copy:DAT /dcopy:T /r:2 /w:5 /mir /XD "System Volume Information" "Recycler"

Is there no easier way?

2

1 Answer 1

1

Is there no easier way?

TL;DR: No there isn't.

Robocopy can't on its own summarize two source drives' contents into one destination folder and still keep mirroring each subfolder back to its original source drive.

To do that, Robocopy would've had to somewhere else keep a mapping of subfolders to source drive, and it has no such feature. So you have to maintain that mapping for Robocopy, which is what you suggest in your edit.

BTW, if Robocopy hypothetically had such a feature, what would you expect it to do if the same subfolder name (but different content) shows up on two source drives? (E.g. there's both E:\ServerFolders\X and F:\ServerFolders\X.)

If you can relax your summarizing rules the obvious alternative would be to create subfolders on G: for each of the source drives. E.g. use destinations G:\ServerFolders\DriveF\A, B, ... and G:\ServerFolders\DriveG\C, D, ....

With that you may consider presenting the summarized contents of G:\ServerFolders\DriveF and G:\ServerFolders\DriveG by creating a library if you're on a Windows version that supports them. Or you could get the same effect by creating and maintaining a directory with links to each of the subdirectories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.