VMware Cloud Community
VMOTION
Contributor
Contributor

Export Script

I have seen a lot of discussion around moving vmdk files between ESX Servers. Here is script that we use to move VM's between our Coporate site and our Hosted facility.

#!/bin/bash

\# The following script will break apart the VMDK files into 2 Gig chucks and move them

\# to a share on the USB drive attached to VCM.MHC.TRK

\# set VCM=:/mnt/vcm;export VCM

/usr/bin/clear

if \[ -f '/mnt/export/ULTIDEVXP-1/*.vmdk' ];

then

echo 'ULTIDEVXP-1 is already cloned and exported...!'

/bin/sleep 10

else

/usr/bin/vmware-cmd /vmfs/volumes/VMWare-DevTest1/ULTIDEVXP-1/ULTIDEVXP-1.vmx getstate

/bin/sleep 15

/bin/mkdir -m 777 /mnt/export/ULTIDEVXP-1

/usr/sbin/vmkfstools -i ./vmfs/volumes/VMWare-DevTest1/ULTIDEVXP-1/ULTIDEVXP-1.vmdk -d 2gbsparse ./mnt/export/ULTIDEVXP-1/ULTIDEVXP-1.vmdk

/usr/bin/du -h /mnt/export/ULTIDEVXP-1/*

/bin/sleep 10

fi

if \[ -f /mnt/export/ULTIDEVXP-2/*.vmdk ];

then

echo 'ULTIDEVXP-2 is already cloned and exported...!'

/bin/sleep 10

else

/usr/bin/vmware-cmd /vmfs/volumes/VMWare-DevTest-1/ULTIDEVXP-2/ULTIDEVXP-2.vmx getstate

/usr/bin/sleep 10

/bin/mkdir -m 777 /mnt/export/ULTIDEVXP-2

/usr/sbin/vmkfstools -i ./vmfs/volumes/VMWarre-DevTest-1/ULTIDEVXP-2/ULTIDEVXP-2.vmdk -d 2gbsparse ./mnt/export/ULTIDEVXP-2/ULTIDEVXP-2.vmdk

/usr/bin/du -h /mnt/export/ULTIDEVXP-2/*

/bin/sleep 10

fi

if \[ -f /mnt/export/ULTIDEVDPM/*.vmdk ];

then

echo 'ULTIDEVDPM is already cloned and exported...!'

/bin/sleep 10

else

/usr/bin/vmware-cmd /vmfs/volumes/VMWare-DevTest-1/ULTIDEVDPM/ULTIDEVDPM.vmx getstate

/bin/sleep 15

/bin/mkdir -m 777 /mnt/export/ULTIDEVDPM

/usr/sbin/vmkfstools -i ./vmfs/volumes/VMWare-DevTest-1/ULTIDEVDPM/ULTIDEVDPM.vmdk -d 2gbsparse ./mnt/export/ULTIDEVDPM/ULTIDEVDPM.vmdk

/usr/bin/du -h /mnt/export/ULTIDEVDPM/*

/bin/sleep 10

fi

if \[ -f /mnt/export/ULTIDEVESS/*.vmdk ];

then

echo 'ULTIDEVESS is already cloned and expored...!'

/bin/sleep 10

else

/usr/bin/vmware-cmd /vmfs/volumes/VMWare-DevTest-1/ULTIDEVESS/ULTIDEVESS.vmx getstate

/bin/sleep 15

/bin/mkdir -m 777 /mnt/export/ULTIDEVESS

/usr/sbin/vmkfstools -i ./vmfs/volumes/VMWare-DevTest-1/ULTIDEVESS/ULTIDEVESS.vmdk -d 2gbsparse ./mnt/export/ULTIDEVESS/ULTIDEVESS.vmdk

/usr/bin/du -h /mnt/export/ULTIDEVESS/*

/bin/sleep 10

fi

if \[ -f /mnt/export/ULTIDEVDB/*.vmdk ];

then

echo 'ULTIDEVDB is already cloned and exported...!'

/bin/sleep 10

else

/usr/bin/vmware-cmd /vmfs/volumes/VMWare-DevTest-1/ULTIDEVDB/ULTIDEVDB.vmx getstate

/bin/sleep 15

/bin/mkdir -m 777 /mnt/export/ULTIDEVDB

/usr/sbin/vmkfstools -i ./vmfs/volumes/VMWare-DevTest-1/ULTIDEVDB/ULTIDEVDB.vmdk -d 2gbsparse ./mnt/export/ULTIDEVDB/ULTIDEVDB.vmdk

/usr/bin/du -h /mnt/export/ULTIDEVDB/*

/bin/sleep 10

fi

exit

Ted Haubein
0 Kudos
3 Replies
rsa911
Virtuoso
Virtuoso

Thanks for your input Murphy ... but you will need a moderator to move your post to the correct forum Smiley Wink

Vmware Server is not yet ESX alas Smiley Happy

0 Kudos
oreeh
Immortal
Immortal

Seems I posted too fast...

0 Kudos
RDPetruska
Leadership
Leadership

Moved to ESX/VI Guest OS forum.

0 Kudos