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:

@echo off
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%
if errorlevel 1 (  
    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

FreeNAS Error Creating Pool

command '('gpart', 'create', '-s', 'gpt', '/dev/da8')' returned non-zero exit status 1. If you get this error while trying to create… Read More

May 14, 2019 8:22 am 08:22

Change Grub Default Boot Entry on Linux Mint

i'm dual booting windows and linux mint on my laptop. the grub default is to boot into linux mint, however… Read More

April 23, 2019 7:45 pm 19:45

How to Reset Secure Channel On Active Directory Domain Controller

when you're a little too careless about virtualizing your domain controllers, cloning, migrating, backing up and restoring, returning from vacation… Read More

April 21, 2019 8:14 am 08:14

Run SystemD Script Before System Shutdown

for the sheer hell of it, a few weeks ago i wanted to see if i could properly and successfully… Read More

April 20, 2019 10:14 am 10:14

Learn Systemctl Usage to Manage Systemd Service in Linux

systemd is new service manager for linux. it's a replacement for all previous init systems (sysv/sysvinit & ubuntu's upstart) and… Read More

April 20, 2019 7:55 am 07:55

Force Delete Windows Server DHCP Failover Relationship

if you've found yourself here then chances are you messed up one of your domain controllers or at least one… Read More

April 20, 2019 5:54 am 05:54