Robocopy copied Delta files to another location

robocopy is a great tool for making full/incremental copies and I like to use it for Backups. One thing, I still haven´t figured out: How to treat the Delta files specifically

Situation: Source A is being copied to Destination B. Either with switch /MIR or at least with /E

Example

robocopy "E:\A" "\\servername\e$\B" /E /B /R:1 /W:1 /Copyall

Normally, only differential files (Delta) are being copied.

So what if I want to script to compress the newly copied files to an archiv for different purposes? Or If I want to move/copy them to location D ?

So in my opinion, a 3rd location in the Script would be nice

robocopy Source A ; match it with Source B and then copy the Delta to location D within a script we then could compress it

The only thing I can think of is to set the archive bit or check the timestamp, but this is not a very solid solution in my opinion

Is it possible to handle that with robocopy or a script?

5

1 Answer

You could use a batch script like this just change the variable values with your own needs:

@echo off :: This line asks for admin permission since the robocopy /b /copyall requires admin permission net session >nul 2>&1 || (powershell start -verb runas '"%~0"' &exit /b) :: Put Source Folder here set Source=W:\md\Musicas :: Put Comparison Folder here: set Comparison=%userprofile%\desktop\Comparison :: Put Destination of Delta Files Here: set DeltaFiles=%userprofile%\desktop\Delta :: Put the path to the log file here set LogFile=%userprofile%\desktop\Filelist.txt :: Put the path to command line 7zip version here: set seven=C:\Program Files\CLI\7zip\7za.exe :: This graps the files that exist in the original folders but don't exist in the comparision folder and saves them in the logfile robocopy "%Source%" "%Comparison%" /L /NJH /NJS /NC /NS /NDL /E /R:1 /W:1 /Log:"%LogFile%" :: This copies the files in the logfile to the delta folder: For /f "usebackq tokens=*" %%a in ("%LogFile%") do Robocopy "%Source%" "%DeltaFiles%" "%%~nxa" /B /ndl /copyall /s /NJS /NJH /R:1 /w:1 :: This uses 7zip to put the delta folder into a zip file and delete the Delta folder (if you don't want to delete remove -sdel) "%seven%" a -tzip -r -sdel "%~dp0delta.zip" "%DeltaFiles%" :: As an Alternative you could use powershell instead of 7zip to create the zip file: ::Powershell Compress-Archive -Path "%DeltaFiles%" -DestinationPath "%DeltaFiles%\Delta.zip" exit 

enter image description here

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like