Solved

Vmware esxi perl script for backup

Posted on 2012-03-20
16
938 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:seanrhudy
[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:seanrhudy
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 120
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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:seanrhudy
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 120

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE^2) earned 500 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:seanrhudy
ID: 37750880
Is there a more simple guide out there for GhettoVCB besides the one above?
0
 
LVL 120
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:seanrhudy
ID: 37764047
Sorry for the late response, let me give ghettoVCB a try.
0
 

Author Comment

by:seanrhudy
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 120
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:seanrhudy
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 120
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:seanrhudy
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 120
ID: 37778011
youncan connect it advance, and leave it connected, or GhettoVCB will auto mount and demount.

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

Author Comment

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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Trouble adding ESXu host to vCenter 25 69
ESXi vmnic Stand By Status 3 117
setup VMWare environment on Windows 10 17 64
Replacing vNIC in VMware VM with no reboot ? 12 40
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…
In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
Teach the user how to convert virtaul disk file formats and how to rename virtual machine files on datastores. Open vSphere Web Client: Review VM disk settings: Migrate VM to new datastore with a thick provisioned (lazy zeroed) disk format: Rename a…
Teach the user how to use configure the vCenter Server storage filters Open vSphere Web Client:  Navigate to vCenter Server Advanced Settings: Add the four vCenter Server storage filters: Review the advanced settings: Modify the values of the four v…

739 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