Hopefully someone will find this useful!
I tired of looking for a reasonably priced backup solution to go with VCB (which I think is great!) so got down to pulling together a lot of googling to create a reasonable batch script for a simple manual backup rotation.
This is effectively a disk-disk-tape solution, although by 'tape' any storage device available to ntbackup could be used. You could also modify the script to omit the ntbackup parts and keep the vcb backup files
The calls the ntbackup are specifically dewsigned to avoid any tape management. The tape currently in the drive is erased, and the backup is written. It is ejected at the end of the operation so that it can be manually rotated.
Hell you can modify if however you like - just share it back to the community if you make it do something nice!
Read the 'Terms of Use' for Community sample code! No warranty is offered on this script, it is for your own reference. If you choose to use it for production use, I cannot guarantee your backup. .. Use entirely at your own risk
No really - go and read the terms of use
A Windows OS VCB Backup proxy machine, with VCB fully installed
Enough disk space on this server to backup your largest guest
A valid license for VCB on your ESX host
A working backup device that can be used for backup by ntbackup
I use TrapGen () to fire an SNMP trap to my network management station when the backup fails. You could replace this with any other command to make an alert, it just so happens my NMS like SNMP.
Watching the logs is made easy by use of baretail () - just associate this useful proggy with .log files and double-click the log.
Add a user 'backup' to your ESX host with appropriate rights, set a nasty obfuscated password
Add the environment variable vmpwd to your VCB backup proxy machine, setting it's
value to the password
Make a working directory on your VCB backup proxy machine. For example C:\Backup
Make a subdirectory script
Make a subdirectory vcbmount (your temporary backup storage before going to tape)
Create a script file backup.cmd and paste in the code
Use Task Scheduler or similar to make a job, redirecting output to a backup.log file in your backup directory
You can test by doing a run now on your task
Change the parameters at the top of the script to appropriate values for your system
Find LTO Ultrium and Quantum LTO - change these to your tape library name. For some reason I haven't managed to parameterise these
If you're not using network based disk method, change the -m nbd parameter appropriately
If you want to use TrapGen.exe then put the executable in your script subfolder, and create another command file backup_failed.cmd to send the trap according
to your requirements. Alternatively make this script take whatever alert action you require.
::back up all guests on a specified ESX host listed in a control file populated by listing guests on the host @echo off set debug=OFF for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j-%%k-%%l for /f "Tokens=1" %%i in ('time /t') do set tm=-%%i set tm=%tm::=-% set dtt=%dt%%tm% set skipguest=: rem -- SET YOUR VALUES FOR THE FOLLOWING set bd=C:\Backup set esxhost=myesxhost echo --%date% %time% - Starting Backup script for ESX host %esxhost% at %dtt% IF "%debug%"=="ON" (echo DEBUG MODE ACTIVE - NO ACTIONS WILL BE TAKEN) echo Refreshing RSM library IF "%debug%"=="OFF" (rsm.exe refresh /LF"Quantum LTO 2 Tape Drive") echo --%date% %time% - Discovering Guest list for ESX host %esxhost% "C:\Program Files\VMware\VMware Consolidated Backup Framework\vcbvmname" -h %esxhost% -u backup -p %vmpwd% -s Any -L 0 > %bd%\script\%esxhost%_vm_list.txt echo Making initial backup of scripts and RSM database ::the next command is REALLY fussy don't fiddle with it if possible! IF "%debug%"=="OFF" (ntbackup.exe backup "@%bd%\script\InitialLocal.bks" /n "TAPE-%esxhost%-%dtt%" /d "SET-%esxhost%-%dtt%" /snap:on /v:no /r:no /rs:no /hc:on /m normal /j "JOB" /l:f /p "LTO Ultrium" /um) if ERRORLEVEL 1 GOTO :errexit echo Entering VM Backup loop for /F "skip=10 tokens=1,2 delims=:" %%i IN (%bd%\script\%esxhost%_vm_list.txt) DO ( IF "%%i%"=="name" ( echo %date% %time% - Starting VCB backup of guest %%j IF "%debug%"=="OFF" ( IF EXIST %bd%\vcbmount\%%j (RD /S /Q %bd%\vcbmount\%%j) "C:\Program Files\VMware\VMware Consolidated Backup Framework\vcbMounter" -h %esxhost% -u backup -p %vmpwd% -a name:%%j -r %bd%\vcbmount\%%j -t fullvm -m nbd ) if NOT ERRORLEVEL 1 ( echo %date% %time% - Starting backup to tape of guest %%j IF "%debug%"=="OFF" (ntbackup.exe backup %bd%\vcbmount\%%j /a /t "TAPE-%esxhost%-%dtt%" /snap :off /v:no /r:no /hc:on /m normal /l:f ) if NOT ERRORLEVEL 1 ( echo %date% %time% - successful tape backup of guest %%j ) ELSE ( echo %date% %time% - failed tape backup of guest %%j set skipguest=%skipguest%,%%j ) ) ELSE ( echo %date% %time% - Failed VCB snapshot of guest %%j set skipguest=%skipguest%,%%j ) IF "%debug%"=="OFF" (IF EXIST %bd%\vcbmount\%%j (RD /S /Q %bd%\vcbmount\%%j)) ) ) echo %date% %time% - Ended VM Backup loop IF "%skipguest%"=="" ( echo --%date% %time% - Generating SNMP trap due to skipped guest CALL backup_failed.cmd ) IF "%debug%"=="ON" ( echo IN DEBUG MODE - FORCING SNMP TRAP CALL backup_failed.cmd ) echo Ejecting tape IF "%debug%"=="OFF" (rsm.exe eject /PF"TAPE-%esxhost%-%dtt% - 1" /astart) echo Guests not backup up or skipped%skipguest% echo --%date% %time% - Ending Backup script for ESX host %esxhost% goto :finish :errexit echo There was an error existstatus returned from the initial backup command echo --%date% %time% - Generating SNMP trap due to skipped guest CALL backup_failed.cmd :finish
The timestamp written to the logs doesn't update - really need to make a function call for this
Couldn't parameterise the tape library name and similar parameter for the RSM refresh for some reason - I blame the ntbackup command as this is very fussy!
NBD method not parameterised
Very Nice! Thanks for the contribution! Now when I tell someone "Or..you could create an NTBackup script" I can refer them to this doc.
Dave Convery
VMware vExpert 2009
http://www.dailyhypervisor.com
Careful. We don't want to learn from this.
Bill Watterson, "Calvin and Hobbes"
You are very welcome! The info came from this great community, and some other similar ones. I just put all the pieces together