| | h2. Description |
| | |
| | These scripts allow you to take automated offline backups of your XenServer 5.0 Virtual Machines, shutting them down and restarting them after backup. |
| | |
| | *Script Name* *Usage* |
| | vmbackup-single-guest.pl Single VM backup specified by command line argument |
| | vmbackup-from-vm-guest-list.pl Selective VM backup from a list |
| | vmbackup-all-guests.pl Complete VM backup within resource pool |
| | |
| | Use these scripts if you can't perform snapshot based backups and need to shutdown your VM's to perfom a 'VM Export' based backup. This is the only type of full VM back available if you are using XenServer 5.0. |
| | |
| | I wrote/modified these scripts so that we could backup our VM's *{+}before{+}* upgrading to XenServer 5.5. |
| | |
| | This script is based on [jeremy tirrell's|http://community.citrix.com/display/~jtirrell] "[0 downtime snapshot based XENServer 5.5 backup script|http://community.citrix.com/display/xs/0+downtime+snapshot+based+XENServer+5.5+backup+script.?showComments=true&showCommentArea=true#addcomment]" |
| | \\ |
| | |
| | h2. Download |
| | |
| | | [Download All|http://community.citrix.com/pages/downloadallattachments.action?pageId=102236496] |
| | |
| | |
| | [http://community.citrix.com/download/attachments/102236496/vmbackup-single-guest.pl] |
| | [http://community.citrix.com/download/attachments/102236496/vmbackup-from-vm-guest-list.pl] |
| | [http://community.citrix.com/download/attachments/102236496/vmbackup-all-guests.pl] |
| | |
| | h2. Change Log/Enhancements |
| | |
| | \* Replaced snapshot creation with vm-shutdown and vm-export for offline backups |
| | \* Added power-state checks |
| | \* Added automatic vm restart upon backup completion |
| | \* Added Status Bar Progress using CPAN Smart::Comments and some debug information |
| | \* Added POD documentation |
| | |
| | h2. Code Snippet |
| | |
| | {code} |
| | print("Shuting down: ".$VMName ."\n"); #Shuting down the VM |
| | $vm_shutdown_cmd = "xe vm-shutdown power-state=running uuid=$guest"; ### [<now>] Shutting down running VM... |
| | $status = `$vm_shutdown_cmd`; |
| | |
| | if ($?) { #checking if shutdown was successfull |
| | print("Error shuting down " .$VMName." using command [$cmd]\n"); |
| | } else { |
| | |
| | print($VMName.": was shutdown\n"); |
| | $Message .= $VMName." was shutdown\n"; |
| | } |
| | |
| | $fdate = `date +%d%m%y`; #get the current date in a format we can write |
| | print("Exporting: ".$VMName."\n"); #export the VM |
| | $Message .= "Exporting: ".$VMName."\n"; |
| | $exportstring = $backupdir.$VMName.".xva-".$fdate; |
| | $status= `xe vm-export vm=$guest filename=$exportstring`; ### [<now>] Performing VM export... |
| | print($status."\n"); |
| | $Message .= $status."\n"; |
| | |
| | $restartStatus= `xe vm-start power-state=halted vm=$guest`; ### [<now>] Restarting VM... |
| | print($restartStatus."\n"); |
| | $restartMessage .= $restartStatus."\n"; |
| | {code} |
| | POD Documentation (run perldoc vmbackup.pl) |
| | {code} |
| | __END__ |
| | # Perldoc documentation |
| | =pod |
| | =head1 NAME |
| | Xen Virtual Machine Backup Script |
| | |
| | =head1 SYNOPSIS |
| | |
| | At the DOM0 console type I<perl -w backup-offline.pl>. |
| | |
| | =head1 DESCRIPTION |
| | |
| | This script will create a list of all available virtual machines running on the XenHost it is run except DOM0. It will then attempt to firstly, shutdown each vm in turn, export the vm to a .xva disk file. |
| | |
| | After attempting the export the script will restart each vm it had previously shutdown. |
| | {code} |
| | |
| | h2. Disclaimer |
| | |
| | These software applications are provided to you as is with no representations, warranties or conditions of any kind. You may use and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software application may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the software application fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the software application. In no event should the code be used to support of ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SOFTWARE APPLICATION, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the code. |