VMware

This Question is Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
4 Replies Last post: Nov 19, 2009 4:06 PM by AlbertWT  

VCB Batch Logging/History/Mail or VDR Mail Notification posted: Nov 3, 2009 2:39 AM

Click to view benny-ulsamer's profile Lurker 3 posts since
May 16, 2006

Hi there,

im looking for a nice solution to backup our VM environment. First: The solution should be at no cost. I know that there are products like vranger and so on, but there is no budget for something like that...

First: I tried VMWare Data Recovery. Is a nice tool but i have some "problems" with it:

  • I havent found any way to send mail notifications. I found that there is a operations_log.utx file under /var/vmware/datarecovery in the data recovery VM. Has anyone tried to export and edit this file and send as a email-report or something like this? This would be nice, so i don't have to look every day in the "Data Recovery" Tab if the backups are successful...

Because of that the Data Recovery Utility is just licensed in Advanced and higher versions of vSphere i'm looking for a solution to backup standard esx-hosts.

So i started to script something with VCB.

My goal is to get a script which can backup machines from any host connected to Virtual Center. The script should be a batch script because of that other administrators understand what i've scripted. At this time my script creates per task a backup of all virtual disks connected to the vm over lan to a backupshare.

What i want to have:

  • I want to have a backuphistory. I set the maximum backup time to hold backups into a variable. Then every time a backuptask runs the backupfolders will be renamed (backup1 will be backup2, backup2 will be backup3 and so on) and the backupfolder with the name of the "hold backups" value should be deleted. So i get a history... Anyone experience with this?

  • Then i would write what my script is doing into a logfile which should be send per email with blat.exe. Here i need a opportunity to create logfiles with virtualmachinename and date in the dataname and an opportunity to delete logifles after a defined timeframe.

Here my script:

REM *********************
REM * Backupjob XP *
REM *********************

REM Laufwerks- und Pfadvariablen werden gesetzt...
set RootLaufwerk=C:
set BackupLaufwerk=Q:
set Backupshare=\\fileserver\VCB

REM Allgemeine Variablen werden gesetzt...
set vcserver=vc.testdom01.local

set user=vcbuser
set pass=vcbuser

set vcbpath=%ProgramFiles%\Vmware\Vmware Consolidated Backup Framework

REM Variablen der zu sichernden VM werden gesetzt...
set vmname=XP

set moref=vm-304
set backupfolder=%vmname%

REM Backuplaufwerk wird verbunden...
net use %BackupLaufwerk% %Backupshare%
sleep 5

REM Bereinigung der alten Backups...
%BackupLaufwerk%
if not exist %backupfolder% goto backup
rd /s /q %backupfolder%
goto backup

REM Durchführung des Backups...
:backup
%RootLaufwerk%
sleep 5
"%vcbpath%\vcbmounter" -h %vcserver% -u %user% -p %pass% -a moref:%moref% -r %BackupLaufwerk%\%backupfolder% -t fullvm -M 0 -F 0 -m nbd -L 4
%RootLaufwerk%
sleep 5

REM Backuplaufwerk wird getrennt..
net use %BackupLaufwerk% /delete

REM Backupjob beeendet.


Click to view MattMarcos's profile Novice 11 posts since
Jun 11, 2009
Hi there. We do a VERY similar thing for our production private cloud. Works a treat. It doesn't have the fancy declaractions or error checking but the process is very visible to our It staff when there's a problem or something gets "stuck"!

I don't like to load our SAN to heavily so the process is a serial one, one VM after another. The treat is when a new VM is created all we have to do is add the VM name to a text file for it to be added to the nightly backups.

Our setup is a typical private cloud on a FC SAN with a VCB proxy box (P2V victim reused!). The VCB proxy has a 2Gb FC HBA connecting it to the SAN. The VCB is then connected to an old MSA20 DAS for all the backups (approx 2TB).

3 files are for the script. All located in the VCB program folder on C: drive of the VCB proxy.

vcb_list.txt - text file containing VM names


VM1
XPbox
Serverblah
DNS
DC1
DC2
vcb_doit.cmd - batch file called each night at 12am. This drives the backups, called using Scheduled Tasks.

c:
cd\ cd "Program Files\VMware\VMware Consolidated Backup Framework"
FOR /F %%a IN (vcb_list.txt) DO vcb_work.cmd %%a
vcb_work.cmd - guts of the operation.

e:
cd\ cd vcb
rmdir /s /q "%1PREVIOUSVer2"
move "%1" "%1PREVIOUSVer2"
"C:\Program Files\VMware\VMware Consolidated Backup Framework\vcbmounter.exe" -h VCSERVER -u VCBPROXYUSER -p VCBPROXYUSERPASS -a name:"%1" -r "e:\vcb\%1" -t fullvm > "%temp%\%1_vcb.log"
robocopy "e:\vcb\%1" "\\OFFSITESERVER\d$\vcb\%1" /mir /np >> "%temp%\%1_vcb.log"
blat "%temp%\%1_vcb.log" -to EMAILADDRESS -subject "VCB Backup of %1"
c:
cd\ cd "C:\Program Files\VMware\VMware Consolidated Backup Framework"
What it does.

  1. For any VM in the text file vcb_list.txt
  2. Remove the 2nd last previous backup of this machine.
  3. Move the current backup to the last previous backup of this machine.
  4. Run a new VCB backup (SAN mode) of this machine, log the detail to a NEW text file in the temp folder.
  5. Sync the remote backup with the new VCB backup files, log the detail to the same text file in the temp folder.
  6. Email the log file generated in steps 4. & 5. to the IT dept systems notification email.
  7. Return to the VCB exe directory for next VCB file. (lazy code, I know!)

I know for sure it can be written better (and I welcome suggestions). The main issue is that if a backup job gets stuck (eg: VCB error, local VCB disk full, remote VCB disk full) it does need manual intervention. It is monitored well though and works well for us. The email notifications (or lack of) are seen by several people in the IT dept and they know Backups = Job security, lol...

There is also another set of scripts basically the same as this for VM's backed up on a weekly basis.

It takes 17 hours to do a full cloud backup of 21 VM's (approx 2TB when compacted via vcbmounter). Note this includes a copy of each VCB to a remote server as well over 1Gb fibre.

Hope this helps!

cheers,

Matt.

Click to view MattMarcos's profile Novice 11 posts since
Jun 11, 2009
Hey Benny. Not a problem mate. :)

Would you care to post your code/scripts? I am always looking for ways to improve our VCB driven backups as well.

Cheers,

Matt.
Click to view AlbertWT's profile Expert 456 posts since
Apr 7, 2009

Yes Please, that'd be great to know.

Cheers

Kind Regards,
AWT

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities