Code: Select all
@echo off
rem ****************************************************************
rem Name: tarfiles.cmd
rem Auther: Troy Hockman
rem Description: script for taring vmbak files after vmbak.pl runs
rem ****************************************************************
cls
rem ** Add bsdtar to path **
set Path=%Path%;c:\program files\gnuwin32\bin
rem ** Set vmdk path **
set vmdksdrive=f:
set vmdkspath=\vmbak
rem ** Find only files with vm in ext
dir /b/s %vmdksdrive%%vmkspath%\*.vm* | find /V "tar" > %temp%\vmbakfiles.txt
for /f "tokens=1" %%x in (%temp%\vmbakfiles.txt) do call :vmdir %%x
rem ** Clean up temp files **
del %temp%\vmbakfiles.txt
del %temp%\vmbakdir.txt
del %temp%\vmbakfile.txt
set vmdksdrive=
set vmdkspath=
goto end
rem ** Get directory for current vm file **
:vmdir
dir %1 | find /i "directory of" > %temp%\vmbakdir.txt
for /f "tokens=3" %%y in (%temp%\vmbakdir.txt) do cd %%y
dir /b %1 > %temp%\vmbakfile.txt
for /f "tokens=1" %%z in (%temp%\vmbakfile.txt) do call :vmfile %%z
goto :EOF
rem ** tar and remove the current vm file
:vmfile
echo Taring %1
%vmdksdrive%
bsdtar -zcf %1.tar.gz %1
del %1
c:
goto :EOF
:end
ESX --> vmbk.pl --> SMB --> W3K --> tarfiles.cmd
Code: Select all
@echo off
rem ****************************************************************
rem Name: tarfiles.cmd
rem Auther: Troy Hockman
rem Description: script for taring vmbak files after vmbak.pl runs
rem ****************************************************************
cls
rem ** Add cygwin to path **
set Path=%Path%;c:\cygwin\bin
rem ** Find only files with vm in ext
dir /b/s f:\vmbak\*vm* | find /V "tar.gz" > %temp%\vmbakfiles.txt
for /f "tokens=1" %%x in (%temp%\vmbakfiles.txt) do call :vmdir %%x
rem ** Clean up temp files **
del %temp%\vmbakfiles.txt
del %temp%\vmbakdir.txt
del %temp%\vmbakfile.txt
goto end
rem ** Get directory for current vm file **
:vmdir
dir %1 | find /i "directory of" > %temp%\vmbakdir.txt
for /f "tokens=3" %%y in (%temp%\vmbakdir.txt) do cd %%y
dir /b %1 > %temp%\vmbakfile.txt
for /f "tokens=1" %%z in (%temp%\vmbakfile.txt) do call :vmfile %%z
goto :EOF
rem ** tar and remove the current vm file
:vmfile
echo Taring %1
f:
c:\cygwin\bin\tar.exe -zcf %1.tar.gz %1
c:\cygwin\bin\rm.exe -f %1
c:
goto :EOF
:end