@echo off rem "C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\x64\vsstools\vshadow" rem robocopy c:\Users\Darren H:\Darren /mir /b /efsraw /copyall /eta setlocal @REM test if we are called by VSHADOW if NOT "%CALLBACK_SCRIPT%"=="" goto :IS_CALLBACK @echo Press enter to back up /Users/Darren to M: pause call "\users\darren\personal\my code\backup cleanup.bat" @REM @REM Get the source and destination path @REM rem set SOURCE_DRIVE_LETTER=%~d1 rem set SOURCE_RELATIVE_PATH=%~pnx1 rem set DESTINATION_PATH=%2 set vshadow="C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\x64\vsstools\vshadow.exe" set SOURCE_DRIVE_LETTER=C: set TEMP_GENERATED_SCRIPT="C:\Users\Darren\AppData\Local\Temp\vshadow_set.cmd" set CALLBACK_SCRIPT=%~dpnx0 set SHADOW_VOLUME=B: @REM @REM Create the shadow copy - and generate env variables into a temporary script. @REM @REM Then, while the shadow is still live @REM recursively execute the same script. @REM @echo ... Turn off SuperFetch ... net stop superfetch @echo ...Creating the shadow copy... %vshadow% -nw -p -script=%TEMP_GENERATED_SCRIPT% -exec="%CALLBACK_SCRIPT%" %SOURCE_DRIVE_LETTER% call %TEMP_GENERATED_SCRIPT% del /f %TEMP_GENERATED_SCRIPT% @goto :EOF :IS_CALLBACK setlocal @REM @REM This generated script should set the SHADOW_DEVICE_1 env variable @REM @echo ...Obtaining the shadow copy device name... call %TEMP_GENERATED_SCRIPT% @REM @REM This should copy the file to the right location @REM %vshadow% -el=%SHADOW_ID_1%,%SHADOW_VOLUME% @echo ...Copying from the shadow copy to the destination path... rem /xd *"System Volume Information" *"temporary internet files" *temp *RECYCLER $* /xf pagefile.sys hiberfil.sys *.bak *.cmf /w:0 /r:0 set EXCL=/xd "Application Data" /xd AppData /xf *.!ut set SOURCE_RELATIVE_PATH=\Users\Darren set DESTINATION_PATH=M:\Darren robocopy "%SHADOW_VOLUME%\%SOURCE_RELATIVE_PATH%" "%DESTINATION_PATH%" /mir /b /efsraw /copyall /ndl /xj /xa:sh /a-:a /r:2 /w:5 %EXCL% sleep 10 rem pause :EOF @echo ...Deleting shadow volume... %vshadow% -ds=%SHADOW_ID_1% sleep 3 sync @echo FINISHED!