Папка MyUtils
Revision | c2ca83bb1e55e9a78b54c6bf46a63b866341395f (tree) |
---|---|
Time | 2012-06-09 16:40:17 |
Author | Константин Кошкин <catsoft1940@gmai...> |
Commiter | Константин Кошкин |
Скрипт копирования файла через VSS и утилиты
@@ -0,0 +1,51 @@ | ||
1 | +setlocal | |
2 | + | |
3 | +@REM test if we are called by VSHADOW | |
4 | +if NOT "%CALLBACK_SCRIPT%"=="" goto :IS_CALLBACK | |
5 | + | |
6 | +@REM | |
7 | +@REM Get the source and destination path | |
8 | +@REM | |
9 | + | |
10 | +set SOURCE_DRIVE_LETTER=%~d1 | |
11 | +set SOURCE_RELATIVE_PATH=%~pnx1 | |
12 | +set DESTINATION_PATH=%2 | |
13 | + | |
14 | +@REM | |
15 | +@REM Create the shadow copy - and generate env variables into a temporary script. | |
16 | +@REM | |
17 | +@REM Then, while the shadow is still live | |
18 | +@REM recursively execute the same script. | |
19 | +@REM | |
20 | + | |
21 | +@echo ...Determine the scripts to be executed/generated... | |
22 | + | |
23 | +set CALLBACK_SCRIPT=%~dpnx0 | |
24 | +set TEMP_GENERATED_SCRIPT=GeneratedVarsTempScript.cmd | |
25 | + | |
26 | +@echo ...Creating the shadow copy... | |
27 | + | |
28 | +%~dp0\vshadow.exe -script=%TEMP_GENERATED_SCRIPT% -exec=%CALLBACK_SCRIPT% %SOURCE_DRIVE_LETTER% | |
29 | + | |
30 | +del /f %TEMP_GENERATED_SCRIPT% | |
31 | + | |
32 | +@goto :EOF | |
33 | + | |
34 | +:IS_CALLBACK | |
35 | +setlocal | |
36 | + | |
37 | +@REM | |
38 | +@REM This generated script should set the SHADOW_DEVICE_1 env variable | |
39 | +@REM | |
40 | + | |
41 | +@echo ...Obtaining the shadow copy device name... | |
42 | + | |
43 | +call %TEMP_GENERATED_SCRIPT% | |
44 | + | |
45 | +@REM | |
46 | +@REM This should copy the file to the right location | |
47 | +@REM | |
48 | + | |
49 | +@echo ...Copying from the shadow copy to the destination path... | |
50 | + | |
51 | +copy "%SHADOW_DEVICE_1%\%SOURCE_RELATIVE_PATH%" %DESTINATION_PATH% |