Robocopy /MIR (Win 7 and others)

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 16420
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Robocopy /MIR (Win 7 and others)

Post by ChrisGreaves »

backups.png
I am reading “Robocopy.exe Robust File Copy Utility Version XP01” a.k.a. robocopy.pdf.
I have two backup drives.
I use the 465GB drive at the end of each day to backup my (T:\) data files.
I use the 930GB drive at the end of each week to backup the 465.
My 930GB drive is a vast accumulation of every scrap of data I have ever created.
My 465GB drive represents data created since the last time I reformatted the 465GB drive. Typically this could be a year or two of stuff.

When my hard drive fails I can copy back my 465GB, but I get an awful lot of now-useless chaff.

I recently began re-formatting my 465GB after the backup to the 930GB (each week), and immediately re-running my nightly backup, a process which took about two hours to make a fresh copy of my data drive T: to the 465GB drive.

My backup.bat file uses RoboCopy from the rkTools.exe:-

Code: Select all

 robocopy t:\      y:\%computername% /S /r:0 /w:0 /XJ
I think that I can add the /MIR parameter, equivalent to the /Purge /E combination to a weekly re-backup run, so that AFTER I have backed up my 465GB to the 930GB drive, I can issue a second backup command to “clean up” the 465GB drive, removing folder trees that no longer exist:-

Code: Select all

 robocopy t:\      y:\%computername% /MIR /r:0 /w:0 /XJ
Have I understood the /MIR parameter correctly?
My goal is to maintain, on my daily 465GB drive, a copy of my T: data drive that is never burdened with more than a week of excess chaff.

T:hanks
Chris
You do not have the required permissions to view the files attached to this post.
Most of my hair had already fallen out by the time I learned that mousse is spelled with two esses

User avatar
John Gray
PlatinumLounger
Posts: 5535
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Robocopy /MIR (Win 7 and others)

Post by John Gray »

A couple of points before I start!
1) why are you still using Truecrypt rather than Veracrypt?
2) why aren't you using the version of Robocopy built-in to versions of Windows newer than XP?
(The documentation is another matter...)

/MIR simply means "perform copy and delete operations so as to make the target folder structure and files identical to the source folder structure and files".
It is a one-way process: source -> target.
Nothing is done to the source folder structure and files.

Does that answer your questions?

I have used Robocopy extensively in backups on our WS2008R2 server at work for years, and (just one example) am now using an internal and then an external 4 TB drive to produce daily copies for two months, and monthly copies for two years, to enable file recovery:
Here's an extract [other backup jobs and Roboopy parameters are available!]:

Code: Select all

:: set up the robocopy variables and run it
set source=\\%svr%\%sharename% 
set target=%pathstart%\%sharename%
set parms=/mir /copyall /s /dcopy:t /ndl /np /r:0 /w:0 
set parms=%parms% /xd $Recycle.Bin "System Volume Information" ".dropbox.cache"
robocopy %source% %target% %parms% >> %copylog% 
I find it all works very well - with /MIR you simply have to be careful that you do not delete target folders unexpectedly. The /L parameter (show what would happen if you ran it without the /L parameter) can help.
John Gray

A car crashed into a barrier at speed; nobody was injured, but a front wheel became detached, and slowly rolled down the road.
Driver [sings]: "You picked a fine time to leave me, Loose Wheel"​​

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 16420
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Robocopy /MIR (Win 7 and others)

Post by ChrisGreaves »

John Gray wrote:A couple of points before I start!
John Gray

Truecrypt vs. Veracrypt: I tried Veracrypt when it superseded Truecrypt in April 2015(?). I found that Veracrypt was slow when opening my data file. My understanding is that Veracrypt is more secure than Truecrypt, but I am not sure that the stuff on my data drive is that important. My main purpose in encryption is to render a large part of my hard drive inaccessible (and hence useless) to anyone who steals my cheap laptop from the library while/if my back is turned. AFAIK the FBI is not after me. I think that Veracrypt is a suitable choice for a major organizxation, on the servers and also on the corporate laptops.

RoboCopy (rktools.exe 06/06/2008 on my hard drive 12,049KB) I am using this version because that’s the first version I used. I wrote DOS BATch files to drive a variety of functions and those batch files still work for me. I have not found a reason to upgrade.
OK. The real reason is that I didn’t know that there was a later version. [sulk]Nobody ever tells me anything[/sulk].
Running Robocopy /? Produces text “ROBOCOPY :: Robust File Copy for Windows :: Version XP010”

Thanks for the parameter examples with Robocopy. I was feeling quite good about adding one more parameter (/MIR) to my belt, but now [sulk]I see that I shall have to bone-up on even more knowledge.[/sulk] So I shall explore /dcopy, /ndl, /np, /copyall in my outdated copy of Robocopy.doc, by which time you will have pointed out that I ought to just disable my Robocopy.exe by modifying my System Environment Variables

Code: Select all

“C:\Program Files (x86)\Windows Resource Kits\Tools\;T:\Batlap;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Codebox\BitMeterOS”
and I just know that now you’ve seen that line I’ll be whipped even faster into the future (well, for me, the future)

Anyway, about /MIR ...
Thank you for the confirmation. I appreciate your cautions, and I know that my “/MIR” run (which deletes discarded folders and files from my daily backup drive) should be run only after I have done the weekly run to backup the daily drive to the weekly drive.

Thanks too for the “/L” tip. I contemplated that, but quickly discarded the idea on the grounds that I was never going to read a volume of logging information before running the actual copy job.
Instead, I set up a few dummy folders and files and observed where they ended up (right where I expected) then deleted them from my data drive, re-ran the /MIR and observed that they had disappeared.

Cheers
Chris
Most of my hair had already fallen out by the time I learned that mousse is spelled with two esses

User avatar
John Gray
PlatinumLounger
Posts: 5535
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Robocopy /MIR (Win 7 and others)

Post by John Gray »

ChrisGreaves wrote:Thanks too for the “/L” tip. I contemplated that, but quickly discarded the idea on the grounds that I was never going to read a volume of logging information before running the actual copy job.
The aim of logging what Robocopy has done is to give you adequate and relevant information which you control by judicious use of the various Logging Options, to avoid the amount being excessive. You can do dummy runs with various Logging Options using the L parameter to determine the amount of Stuff which gets produced on your log file.

If you are getting the XP010 Robocopy executable running on Windows 7 you want instead to use that built-in to Windows 7 - it will have unspecified bug fixes compared with XP010!
John Gray

A car crashed into a barrier at speed; nobody was injured, but a front wheel became detached, and slowly rolled down the road.
Driver [sings]: "You picked a fine time to leave me, Loose Wheel"​​