Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- NFS_SERVER=127.0.0.1
- NFS_SHARE=/mnt/VMS
- CONTROL_DOMAIN=`xe vm-list | grep -i -B1 control | grep uuid | sed -e 's/[^:]*: //'`
- function export_ALL
- {
- ALL_VMS=`xe vm-list | grep uuid | sed -e 's/[^:]*: //' | grep -iv $CONTROL_DOMAIN`
- AVAILABLE_VMS=`xe vm-list | grep name | sed -e 's/[^:]*: //' | grep -iv control`
- echo "About to export the following VM's..."
- echo "$AVAILABLE_VMS"
- read -p "Press any key to continue..."
- for uuid in $ALL_VMS
- do
- UUID2NAME=`xe vm-list | grep -A1 $uuid | grep name | sed -e 's/[^:]*: //'`
- echo "Creating snapshot of $UUID2NAME."
- SNAPUUID=`xe vm-snapshot vm=$uuid new-name-label=$UUID2NAME-backup`
- echo "Converting snapshot to virtual machine."
- xe template-param-set is-a-template=false ha-always-run=false uuid=$SNAPUUID
- echo "Exporting the virtual machine to NFS share."
- xe vm-export vm=$SNAPUUID filename=$NFS_SHARE/"$UUID2NAME".xva >/dev/null 2>&1
- echo "Removing original snapshot."
- xe vm-uninstall uuid=$SNAPUUID force=true
- done
- echo
- exit 0
- }
- function check_exit
- {
- if [ $? -gt 0 ]; then
- echo "An error has occured, exiting."
- exit 1
- fi
- }
- export_ALL
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement