From time to time Windows Admins will surprise you with band-aid and bubble gum scripts, that's entirely expected I think. But then again with just about the same irregular interval with a touch of entropy sprinkled on the electrical-fire cake, someone comes along and actually puts together something that works well, and efficiently. Resource efficiency is entirely under-rated and feels like the subject has been coaxed out of conversational existence by the x86 Wintel side of people, for lack of a better term.

In my opinion in order to achieve an efficient, fast executing, and fast to exit backup routine means executing multiple copies of Robocopy running in parallel through the use of spawning multiple copies via start.exe. The reason  for my preference of Robocopy, over say a custom PowerShell function is due to the fact that utilities like robocopy.exe is already in the most "efficient" form as seen by the physical CPU. Compiled binary executables (exe's) will always win versus managed-code which is what PowerShell and regular batch scripts are. Just remember that the lower-level the code (C/C++, Assembly), the closer it is to native machine language, and execution faster due to less compiling needed for translation in binary (0's and 1's), in general. From the processor perspective these are apple's and oranges. Without further adieu:

cd /d %~dp0

::: Generate reproducable new line variable
set nl=^&echo.

for /F "tokens=1-4 delims=/-. " %%i in ('date /t') do (call :set_date %%i %%j %%k %%l)
goto :end_set_date

if "%1:~0,1%" gtr "9" shift
for /F "skip=1 tokens=2-4 delims=(-)" %%m in ('echo,^|date') do (set %%m=%1&set %%n=%2&set %%o=%3)
goto :eof
::: End set date

for /F "eol=; tokens=1,2* delims=," %%i in (robocopy-paths.txt) do (call :process %%i %%j %%k)
goto :eof
start /B robocopy %1 %2 %3 %4 %5 %6 %7 %8 %9
::: More error handling: || echo FAILED: %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
set exit_code=%ERRORLEVEL%
    echo FAILED: %1 %2 %3 %4 %5 %6 %7 %8 %9, return code = %exit_code%
    exit /b %exit_code%
exit /b %exit_code%
goto :eof
%userprofile%\Documents, \\\Public\DFS\visualblind\Documents, /MIR, /ZB, /XO, /XD "C:\Users\visualblind\Documents\Sites", /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
%userprofile%\Desktop, \\\Public\DFS\visualblind\Desktop, /MIR, /ZB, /R:2, /XO, /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
%userprofile%\Downloads, \\\Public\DFS\visualblind\Downloads, /MIR, /ZB, /R:2, /XO, /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
%userprofile%\Pictures, \\\Public\DFS\visualblind\Pictures, /MIR, /ZB, /R:2, /XO, /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
%userprofile%\AppData\Local\Game\Save, \\\Public\DFS\visualblind\AppData\Local\Game\Save, /MIR, /ZB, /R:2, /XO, /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
;echo Robocopy Done%nl%"%username%\Desktop, %username%\Documents, %username%\Downloads, %username%\Pictures, %username%\AppData\Local\Game\Save > \\\Public\DFS\%username%" >> %userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
%userprofile%\Documents, D:\%username%\Documents, /MIR, /ZB, /XO, /XD "C:\Users\visualblind\Documents\Sites", /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
%userprofile%\Desktop, D:\%username%\Desktop, /MIR, /ZB, /R:2, /W:55, /XO, /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
%userprofile%\Downloads, D:\%username%\Downloads, /MIR, /ZB, /R:2, /W:55, /XO, /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
%userprofile%\Pictures, D:\%username%\Pictures, /MIR, /ZB, /R:2, /W:55, /XO, /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
%userprofile%\AppData\Local\Game\Save, D:\%username%\AppData\Local\Game\Save, /MIR, /ZB, /R:2, /XO, /NP, /NFL, /LOG+:%userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt
;echo Robocopy Done%nl%"%username%\Desktop, %username%\Documents, %username%\Downloads, %username%\Pictures, %username%\AppData\Local\Game\Save> D:\%username%" >> %userprofile%\Documents\Temp\robocopy_%mm%_%dd%_%yy%.txt

It is incredibly obvious, and stupidly simple to see the vast differences in resource consumption and vast resource waste coming from the Windows Server arena. Since the NT kernel is closed-source, not you or I can tell what the hell is going on in there. Due to the explosion of virtualization, and more specifically, guest VM resource report-ability, you can look at two idling VM's running on the same physical hardware with the same specs (1 vCPU, 1GB vMem, etc.) and more often than not the Windows Server 2008 R2, 2012, 2012 R2, 2016, 2019 Standard/Enterprise/Datacenter Edition guest is consuming (hogging) at least 2x CPU cycles and consuming 2-3x vMem. Albeit we must also take into account that the Wintel VM is probably providing more numerous services per individual guest (CIFS, ADDS, DHCP, DNS, etc.), so one of these days if I have the time I'll try launching a head-to-head Torvalds vs. Gates competition. Zero-MegaHertz sounds like a good name to me.

Take a break, It is what you think it is. Go ahead, you deserve it.
Disqus Comments Loading...

Recent Posts

VMWare vSphere 6.7 ESXTOP Output Garbled

If your VMWare vSphere 6.x environment command output of esxtop looks like a bunch of garbled gibberish (it's actually CSV… Read More

February 28, 2019 7:39 pm 19:39

Windows 10 GodMode - The Ultimate Administrator Shortcut

Have you ever wondered what life might be like if the Windows 10 OS somehow had a single folder that… Read More

February 28, 2019 7:58 am 07:58

Samsung Galaxy S9 G960/G965 Stock ROM Firmware Download

There could be any number of reasons for needing to flash manufacturer stock OEM firmware on a Samsung Galaxy S9… Read More

January 24, 2019 7:42 am 07:42

Output IP Address with ipconfig Findstr Ethernet Adapter

How many times have you entered  ipconfig /all at the command line to return a single IP address, then have to strain… Read More

January 20, 2019 12:39 am 00:39

AWS SES Assistance in Enterprise Market - A Must Read

Designing e-mail solutions on a large scale can be a complex and costly challenge for a business: you need to… Read More

December 25, 2018 4:01 pm 16:01