Xenserver Script to Import and Export Vm from command line

By | March 24, 2010

I have created a small script, which enables you to take a backup of a Vm running on Citrix Xenserver and Export it on your local machine,
You can also restore an exported vm (IMPORT) to any remote xenserver with this script.
I am also working on the functionality to create scheduled tasks (cron jobs) out of this script so that you can create a backup schedule for your xenserver vm’s
with two options, you can either shutdown a vm and export it, or else you can take a snapshot of a vm and then export that snapshot.
As usual this Xenserver Backup application will be free, and should be avaliable shortly, if you are in need of this, let me know as i already have a beta version running,
however packing an installer is the most tedious part of the whole process 😛

This script has been tested on ubuntu 9 but should work on any linux.

To Run the script, just run
chmod +x IMPEXPVM.sh
./IMPEXPVM.sh

And then follow the instructions on the screen

Please let me know if this was of any help.

You can Download it here IMPEXPVM

2 thoughts on “Xenserver Script to Import and Export Vm from command line

  1. djtremors

    Am I right that one of your lines has a typo (xe vm-import?) as below?

    echo “Starting Export Please Be Patient”
    xe vm-import -s “$SRCSRV” -u “$SRCUSER” -pw “$SRCPASS” filename=”$VM” >> $LOG 2>&1

    My suggestion would be to also export to a secondary disk in case the one with the vms are on dies taking out the backups too.
    Possible rsync to a remote site as well.

  2. Madhurranjan

    Hi Isaac,

    Great work here !! I wanted to ask you how we can automatically assign IP address to a VM if we are creating the VM through an API . Is DHCP the only way ? Any thoughts on this based on your experience ? Been playing around with Cmd and the VIF as you know can only by associated with Mac but not an ip address. It would be great if you can share your experience.

    thanks
    Madhurranjan

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.