Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Vmware esxi perl script for backup

Posted on 2012-03-20
16
Medium Priority
?
983 Views
Last Modified: 2012-04-04
Hello,

I am trying to use the perl script esxi-backup.pl to backup my unlicensed version of VMware ESXI 4.1.  I have one datastore with 2 VM's.  The second VM copys fine, but the first only copies a few bytes of the vmdk file which should be like 100GB.  I've attached the screen shot of what I see when the script runs.
Capture.JPG
0
Comment
Question by:Sean Rhudy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
16 Comments
 

Author Comment

by:Sean Rhudy
ID: 37745652
#
# ESXi 3.5 Backup Script
#
# Autor: Christian Gruetzner
#
#
#############################################################################
#
#2008-08-22  V 1.0 Basic Script
#            Functions:     - create snapshots of all local VM's
#                           - get files from ESX-Datastore to local Store
#                           - exclude unneccessary files from backup
#                           - remove all created snapshots
#                           - actual time in log
#
#############################################################################




my $url = "https://dsesxi01/sdk/vimService";     #URL to your ESX Host
my $username = "root";                                  #Username
my $password = "Gp*4rVS71";                                    #User password
my $snapshotname = "BackupSnap";                        #Name of your Snapshot
my $DSPath = "[datastore1]";                            #Datastore name on ESX Host, example [datastore]
my @VMNames;
$VMNames[0] = "DSDC001";                      #Uncomment the next lines if you like to backup more vm's
$VMNames[1] = "DSAP01";
#$VMNames[2] = "";
#$VMNames[3] = "";
#$VMNames[4] = "";
#$VMNames[5] = "";
#$VMNames[6] = "";
#$VMNames[7] = "";
#$VMNames[8] = "";
#$VMNames[9] = "";
my $RCLIPath = "C:/Progra~1/vmware/VMware~1";           #VI Remote CLI Path (Windows: Use ONLY Short Folder Names!!!!)
my $DestPath = "Z:/";                                   #Destination Path you like to copy to (Windows: Use ONLY Short Folder Names!!!!)

#IMPORTANT!!! -- Under DestPath must exist the VMNames Folder 
#(For Example if your VMNames[0] = "ServerA" and your DestPath = "D:/": D:/ServerA/)
#--------------------------------------------------------
# For the short folder name use "dir /X"










#call the sub function (at the bottom)
&actualtime();
print " ***** Script Start *************************\n\n";

&actualtime();
print " ----- Create Snapshots of running VM's -----";
print "\n\n";
system("perl $RCLIPath/Perl/apps/vm/snapshotmanager.pl --url $url --username $username --password $password --operation create --powerstatus poweredOn --snapshotname $snapshotname");
print "\n\n";





&actualtime();
print " ----- Copy VM files to local storage   -----";
print "\n\n";
my $i = 0;
#special loop for arrays. run as long the array has data
foreach (@VMNames)
{
    #read all available files and save filenames in the cache-array
	my @cache = `perl $RCLIPath/bin/vifs.pl --url $url --username $username --password $password --dir \"$DSPath $VMNames[$i]\"`;
	#run as long the cache array has data and save the value everytime in $filename
	foreach my $filename (@cache)
	{
		#exclude uninterresting files from backup to save backup space
	 	if($filename !~ /.log/ && $filename !~ /.vswp/ && $filename !~ /.vmsn/ && $filename !~ /-delta/)
	 	{
	 		#remove the "\n" at the end of $filename to prevent a error massage in log
			chomp($filename)
			&actualtime();
			print " ----- Copy File: ";
	 		print $filename;
	 		#get files from VM Datastore to a local Storage
			system("perl $RCLIPath/bin/vifs.pl --url $url --username $username --password $password --get \"$DSPath $VMNames[$i]/$filename\" \"$DestPath$VMNames[$i]/$filename\"");
			print "\n";
		}
	}
	$i++;
}
print "\n\n";





&actualtime();
print " ----- Remove Snapshots of running VM's -----";
print "\n\n";
system("perl $RCLIPath/Perl/apps/vm/snapshotmanager.pl --url $url --username $username --password $password --operation remove --powerstatus poweredOn --snapshotname $snapshotname --children 1");
print "\n\n";

&actualtime();
print " ***** Script End ***************************";










#sub function to print the actual time in the log
sub actualtime
{
	my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat,
	    $Jahr, $Wochentag, $Jahrestag, $Sommerzeit) = localtime(time);
	my $CTIME_String = localtime(time);
	$Monat+=1;
	$Jahrestag+=1;
	$Monat = $Monat < 10 ? $Monat = "0".$Monat : $Monat;
	$Monatstag = $Monatstag < 10 ? $Monatstag = "0".$Monatstag : $Monatstag;
	$Stunden = $Stunden < 10 ? $Stunden = "0".$Stunden : $Stunden;
	$Minuten = $Minuten < 10 ? $Minuten = "0".$Minuten : $Minuten;
	$Sekunden = $Sekunden < 10 ? $Sekunden = "0".$Sekunden : $Sekunden;
	$Jahr+=1900;
	
	print "$Jahr-$Monat-$Monatstag $Stunden:$Minuten:$Sekunden";
}

Open in new window

0
 
LVL 3

Expert Comment

by:gorhon
ID: 37746104
ok, but why using vmware vcb backup? please find vcb installation on the web. not hard.
0
 
LVL 123
ID: 37746501
Why don't you use the tried and tested Ghetto VCB?

5. ghettoVCB

http://communities.vmware.com/docs/DOC-8760 ((Will work on FREE ESXi, no licensed required.)

(can be performed whilst the virtual machine is live or powered on)

Above taken from my EE Article


VMware ESX/ESXi Backup Guide
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:Sean Rhudy
ID: 37749750
vcb isn't free.  GhettoVCB looks much more difficult to configure and run.  The perl script was fairly simple to configure and is working for one VM, just not the other.  Any ideas on what's happening?
0
 
LVL 123

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE^2) earned 2000 total points
ID: 37749806
GhettoVCB is simple, supported, developed and maintained by the community.

The PERL script you've found is old and outdated, and developed for ESXi 3.5.
0
 

Author Comment

by:Sean Rhudy
ID: 37750880
Is there a more simple guide out there for GhettoVCB besides the one above?
0
 
LVL 123
ID: 37751994
You download the script and makes changes to the ghettoVCB.conf file.

The URL above is the best source of how to configire ghettoVCB.

If you are not comfortable with scripts, I would suggest  purchasing a $500 License from VMware and Veeam Backup and Replication v6.
0
 

Author Comment

by:Sean Rhudy
ID: 37764047
Sorry for the late response, let me give ghettoVCB a try.
0
 

Author Comment

by:Sean Rhudy
ID: 37777813
Ok, I am configuring Ghetto VCB and have a question.  I want to backup to a NAS drive.  I'm confused on the difference between:

VM_BACKUP_VOLUME=/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS

and

Defining the NFS information

Do I use one or the other?
0
 
LVL 123
ID: 37777840
specify the datastore you need to backup to

so I have a datastore called

/vmfs/volumes/nfs

i would use thatbin the config
0
 

Author Comment

by:Sean Rhudy
ID: 37777946
I don't want to backup to a datastore, I want to backup to a Network attached storage device. Can I do that?
0
 
LVL 123
ID: 37777967
yes, but needs to be added to the host server.

GhettoVCB can automatically mount and dismount the network attached storage, or you can attach to ESXi permenantly. network attached storage connected to ESX server is a datastore.

option is yours.
0
 

Author Comment

by:Sean Rhudy
ID: 37777995
Got ya, so would I connect the Nas device as a datastore prior to doing this, or will GhettoVCB do it for me?
0
 
LVL 123
ID: 37778011
youncan connect it advance, and leave it connected, or GhettoVCB will auto mount and demount.

choice is yours.
0
 
LVL 123
ID: 37778015
less configurationm and issues if you connect it.
0
 

Author Comment

by:Sean Rhudy
ID: 37808313
I have ghettoVCB setup but am having errors in the backups, I will open a new question.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
This video shows you how to use a vSphere client to connect to your ESX host as the root user. Demonstrates the basic connection of bypassing certification set up. Demonstrates how to access the traditional view to begin managing your virtual mac…
This video shows you how easy it is to boot from ISO images for virtual machines with the ISO images stored on a local datastore on the ESXi host.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question