VM Backups

ESX 2.5.x
Post Reply
thockman
Site Admin
Posts: 104
Joined: Thu Dec 15, 2005 5:51 pm
Location: Kansas City
Contact:

VM Backups

Post by thockman » Thu Apr 20, 2006 9:21 am

I have switched to using bsdtar for windows, seems faster.

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

Here is a cmd file that, using cygwin, tars the vmdk files that have been exported using vmbk.pl. The purpose of doing it this way is to get the processing off of the ESX server asap.

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


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest