Backupscript for VMFS Partition Header and information

From Vmuser.com Knowledge Base

Revision as of 11:03, 26 October 2007; Admin (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search

Playing wrong with VMFS 3 partitions (manual partitioning) or errors during LUN replication can destroy the partition information of the VMFS Datastore.

Therefore a regular backup of the partition table and the header informations should be done.

with the following script every VMFS Datastore Header/Partition information are backed up and saved under /tmp. These backup files are helping VMware Support or yourself if you are experienced enough for restoring.

Use at your own risk!!

#!/usr/bin/perl
# backup vmfs3 header by Dennis Zimmer 

@datastores = `/usr/sbin/esxcfg-vmhbadevs -m`;

print "\n========================================\n";
print "========= starting VMFS Backup =========\n";
print "========================================\n";

foreach (@datastores)
{
($lunid, $devname, $vmfsuuid) = split;
($buffer, $fname) = split (/:/, `/usr/sbin/vmkfstools -P /vmfs/volumes/${vmfsuuid} | grep "File system label"`);
$fname =~ s/^\s+//;
$fname =~ s/\s+$//;
print "\n== Sichere $devname \t $vmfsuuid \t $fname ==\n";
print "\n== Backup .sf Dateien ==\n";
system "tar czvf /tmp/\"$fname\"-$vmfsuuid.tgz /vmfs/volumes/$vmfsuuid/.*.sf";
print "\n== Backup LUN Header ==\n";
system "dd if=$devname of=/tmp/vmfsdump-\"$fname\"-$vmfsuuid.bin bs=1024 count=2480";
}

print "\n========================================\n";
print "========== Backup finished =============\n";
print "========================================\n";
Navigation