├── test.lst ├── README.md ├── settings.cfg └── Xen_Backup.sh /test.lst: -------------------------------------------------------------------------------- 1 | 1Tbackup 2 | Tbackup2 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Xen-pocalypse 2 | ============= 3 | 4 | Bash script to backup Citrix Xen VMs. 5 | The guide for it is on HTG: 6 | http://www.howtogeek.com/131181/how-to-backup-citrix-xen-vms-for-free-with-xen-pocalypse-bash/ 7 | -------------------------------------------------------------------------------- /settings.cfg: -------------------------------------------------------------------------------- 1 | #This is the settings file for the Xen-pocalypse backup script. 2 | BackupLocation="/var/run/sr-mount/%UUID%" 3 | SendEmail_location="/root/Xen-pocalypse/sendEmail-v1.56/sendEmail.pl" 4 | EMAIL_FROM="Xen-hostname@yourdomain.com" 5 | EMAIL_TO="yourname@yourdomain.com" 6 | EMAIL_SMART_HOST="the-relevent-smarthost:port" 7 | EMAIL_AUTH_USERNAME="" 8 | EMAIL_AUTH_PASSWORD="" 9 | ENABLE_COMPRESSION="no" # Change to "yes" to enable. 10 | CHECK_FREE_SPACE="yes" # To disable free space checking change to "no". 11 | LIST_METHOD="TAGs" # The Default option is “TAGs” and the other option is "FILE". 12 | DEBUG="0" # To disable debugging, set to "0". 13 | # Possible debugging flags are: "ALL", EmailENABLed", "ExportENABLed", 14 | # "Export_func", "name_2_uuid", "uuid_2_name", "state", "org_state", 15 | # "vm_properties", "start", "shutdown", "deps_state_custom", 16 | # "space_for_backup_check" amd "backuplocation". 17 | -------------------------------------------------------------------------------- /Xen_Backup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | xencmd="/opt/xensource/bin/xe" 3 | 4 | logger_xen() 5 | { 6 | if [[ "$2" = "expose" || $DEBUG != "0" && -n $DEBUG ]]; then 7 | logger_cmd="logger -s -t Xen-pocalypse " 8 | else 9 | logger_cmd="logger -t Xen-pocalypse " 10 | fi 11 | 12 | if [[ -n "$1" ]]; then 13 | DATE="$( date +%D-%T )" 14 | $logger_cmd " $1" #useful for manual runs, but not for Cron ones. 15 | Email_VAR="$Email_VAR $DATE: $1\\n" 16 | [[ "$2" = "expose" ]] && Email_func "$1" "$3" 17 | else 18 | $logger_cmd " " 19 | Email_VAR="$Email_VAR \n" 20 | fi 21 | } 22 | Email_func() 23 | { 24 | MSG="$1" 25 | [[ ! -x $SendEmail_location ]] && logger_xen "The SendEmail_location \"$SendEmail_location\", does NOT point to a perl executable." && continue 26 | [[ -z "$2" ]] && EMAIL_SUB="Exception" || EMAIL_SUB="$2" 27 | [[ "$2" = "Started" ]] && MSG="$MSG \\nThe VM list is set to be obtained using \"$LIST_METHOD\".\\nThe parameter that will be used is: \"$SECOND_PARAM\"." && [[ $LIST_METHOD = "TAGs" ]] && EMAIL_SUB="$EMAIL_SUB for $SECOND_PARAM" 28 | [[ "$2" =~ .*Exception.* ]] && MSG="$MSG \\nThe VM list was obtained using \"$LIST_METHOD\".\\n" && if [[ $LIST_METHOD = "FILE" ]]; then MSG="$MSG \n\n The list was $FILELIST"; else MSG="$MSG \n\n The TAG was $TAG" ;fi 29 | if [[ $DEBUG = "0" || $DEBUG =~ .*EmailENABLed.* ]] && [[ -e $SendEmail_location ]] ;then 30 | if [[ -n $EMAIL_AUTH_USERNAME && -n $EMAIL_AUTH_PASSWORD ]];then 31 | $SendEmail_location -f "$EMAIL_FROM" -t "$EMAIL_TO" -u "Xen_backup - $EMAIL_SUB" -s "$EMAIL_SMART_HOST" -q -m "$MSG" -xu "$EMAIL_AUTH_USERNAME" -xp "$EMAIL_AUTH_PASSWORD" 32 | else 33 | $SendEmail_location -f "$EMAIL_FROM" -t "$EMAIL_TO" -u "Xen_backup - $EMAIL_SUB" -s "$EMAIL_SMART_HOST" -q -m "$MSG" 34 | fi 35 | fi 36 | } 37 | xen_xe_func() 38 | { 39 | case $2 in 40 | name_2_uuid) 41 | VM_UUID="$( $xencmd vm-list name-label=$1 | grep uuid | awk '{ print $5 }' )" 42 | [[ $DEBUG = "ALL" || $DEBUG =~ .*name_2_uuid.* ]] && logger_xen "VM_UUID for \"$1\" has been set to \"$VM_UUID\"." 43 | ;; 44 | uuid_2_name) 45 | VM_NAME_FROM_UUID="$( $xencmd vm-list uuid=$1 | grep name | awk '{for (i = 4; i <= NF; i++) {printf("%s ", $i);} }' )" 46 | [[ $DEBUG = "ALL" || $DEBUG =~ .*uuid_2_name.* ]] && logger_xen "VM_NAME_FROM_UUID has been set to \"$VM_NAME_FROM_UUID\" for \"$1\"." 47 | ;; 48 | state) 49 | POWERSTATE="$( $xencmd vm-param-get param-name=power-state uuid=$1 )" 50 | [[ $DEBUG = "ALL" || $DEBUG =~ .*state.* ]] && logger_xen "POWERSTATE for \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\" has been set to \"$POWERSTATE\"." 51 | ;; 52 | org_state) 53 | [[ $DEBUG = "ALL" || $DEBUG =~ .*org_state.* ]] && logger_xen "Org sate invoked for \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\"." 54 | xen_xe_func "$1" "state" 55 | ORG_STATE=$POWERSTATE 56 | [[ $DEBUG = "ALL" || $DEBUG =~ .*org_state.* ]] && logger_xen "ORG_STATE for \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\" as been set to \"$ORG_STATE\"." 57 | ;; 58 | export) 59 | xen_xe_func "$1" "uuid_2_name" 60 | if [[ $ENABLE_COMPRESSION = "yes" ]]; then 61 | export_cmd="$xencmd vm-export compress=true uuid=$1 filename=$BACKUP_FILE_AND_LOCAL_LONG" 62 | else 63 | export_cmd="$xencmd vm-export uuid=$1 filename=$BACKUP_FILE_AND_LOCAL_LONG" 64 | fi 65 | if [[ $DEBUG = "0" || $DEBUG =~ .*ExportENABLed.* ]]; then 66 | $export_cmd > /dev/null 67 | if [[ "$?" -eq 0 ]]; then 68 | EXPORT="OK" 69 | logger_xen "Successfully exported \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\" :)" 70 | [[ $DEBUG = "ALL" || $DEBUG =~ .*Export_func.* ]] && logger_xen "Will now wait for 5s, to let \"$1\" time to cool-down." 71 | sleep 5 72 | else 73 | EXPORT="FAILED" 74 | logger_xen "Failed to export :\ \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\"" "expose" 75 | #Email_func "Failed to export $1" "Exception!!" 76 | #continue 77 | fi 78 | else 79 | logger_xen "Export CMD was: \"$export_cmd\"" 80 | EXPORT="OK" 81 | logger_xen "Debug is turned on, skipped actually exporting to save time." 82 | fi 83 | ;; 84 | vm_properties) 85 | [[ $DEBUG = "ALL" || $DEBUG =~ .*vm_properties.* ]] && logger_xen "Vm_properties for \"$1\" has been invoked." 86 | xen_xe_func "$1" "vm-existance" 87 | VM_UUID="$1" 88 | xen_xe_func "$VM_UUID" "uuid_2_name" 89 | xen_xe_func "$VM_UUID" "deps_state_custom" 90 | ;; 91 | vm-existance) 92 | if [[ -z "$( $xencmd vm-list uuid=$1 )" && -z "$( $xencmd vm-list name-label=$1 )" ]]; then 93 | logger_xen "The VM \"$1\" is in the backup list, but does not exist?" "expose" 94 | continue 95 | fi 96 | ;; 97 | start) 98 | [[ $DEBUG = "ALL" || $DEBUG =~ .*start.* ]] && logger_xen "StartVM func invoked." 99 | VM_TO_START="$1" 100 | [[ "$3" = "child" ]] && VM_TO_START="$( $xencmd vm-list name-label=$1 | grep uuid | awk '{ print $5 }' )" 101 | [[ $DEBUG = "ALL" || $DEBUG =~ .*start.* ]] && logger_xen "VM_TO_START was set to: \"$VM_TO_START\". (Its name is: \"$VM_NAME_FROM_UUID\")" 102 | $xencmd vm-start uuid="$VM_TO_START" 103 | if [[ "$?" -eq 0 ]] ; then 104 | logger_xen "Successfully started \"$1\"" 105 | else 106 | logger_xen "FAILED to start \"$1\"" 107 | logger_xen "Waiting for 10s and retrying to start VM \"$1\"" 108 | sleep 10 109 | $xencmd vm-start uuid="$1" 110 | if [[ "$?" -eq 0 ]] ;then 111 | logger_xen "Retry to start VM \"$1\" was successful" 112 | else 113 | logger_xen "FAILED again to start \"$1\". Will sleep for $WARM_UP_DELAY seconds and try a third and final time" 114 | sleep $WARM_UP_DELAY 115 | $xencmd vm-start uuid="$1" 116 | if [[ "$?" -eq 0 ]] ;then 117 | logger_xen "Retry to start VM \"$1\" was successful" 118 | else 119 | logger_xen "FAILED twice to start \"$1\"" "Exception!!" "expose" 120 | #Email_func "FAILED twice to start $1" "Exception!!" 121 | continue 122 | fi 123 | 124 | fi 125 | fi 126 | ;; 127 | shutdown) 128 | xen_xe_func "$1" "state" 129 | if [[ $POWERSTATE != "halted" ]] ; then 130 | [[ $DEBUG != "0" ]] && logger_xen "About to: \"$xencmd vm-shutdown uuid=$1\"." 131 | $xencmd vm-shutdown uuid="$1" 132 | if [[ "$?" -eq 0 ]] ;then 133 | logger_xen "Successfully shutdown VM \"$1\"." 134 | [[ $DEBUG = "ALL" || $DEBUG =~ .*shutdown.* ]] && logger_xen "Will now wait for 5s, to let \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\" time to cool-down" 135 | sleep 5 136 | else 137 | logger_xen "Something went wrong when shutting down the VM \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\"" "expose" 138 | continue 139 | fi 140 | fi 141 | xen_xe_func "$1" "state" 142 | ;; 143 | deps_state_custom) 144 | DEP_STATE="null" 145 | CHILDREN_LIST="null" 146 | PARENT="null" 147 | [[ $DEBUG = "ALL" || $DEBUG =~ .*deps_state_custom.* ]] && logger_xen "The deps_state_custom func has been invoked for \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\"." 148 | CHILDREN_LIST="$( $xencmd vm-param-get uuid=$VM_UUID param-name=other-config param-key=XenCenter.CustomFields.Children 2> /dev/null )" 149 | if [[ "$?" -eq 0 ]] ; then 150 | logger_xen "VM has children. They are: $CHILDREN_LIST." 151 | for CHILD_NAME in $CHILDREN_LIST; do 152 | xen_xe_func "$CHILD_NAME" "name_2_uuid" 153 | CHILDREN_LIST_UUID="$CHILDREN_LIST_UUID $VM_UUID" 154 | [[ $DEBUG = "ALL" || $DEBUG =~ .*deps_state_custom.* ]] && logger_xen "The current CHILDREN_LIST_UUID is: \"$CHILDREN_LIST_UUID\"." 155 | done 156 | DEP_STATE="dep_parent" 157 | else 158 | [[ $DEBUG = "ALL" || $DEBUG =~ .*deps_state_custom.* ]] && logger_xen "No Children were found for \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\". looking for a PARENT." 159 | PARENT="$( $xencmd vm-param-get uuid=$VM_UUID param-name=other-config param-key=XenCenter.CustomFields.Parent 2> /dev/null )" 160 | if [[ "$?" -eq 0 ]] ; then 161 | [[ $DEBUG = "ALL" || $DEBUG =~ .*deps_state_custom.* ]] && logger_xen "VM has a Parent. It is: \"$PARENT\"." 162 | DEP_STATE="dep_child" 163 | else 164 | [[ $DEBUG = "ALL" || $DEBUG =~ .*deps_state_custom.* ]] && logger_xen "No Parent was found for \"$VM_NAME_FROM_UUID\"." 165 | fi 166 | fi 167 | [[ $DEBUG = "ALL" || $DEBUG =~ .*deps_state_custom.* ]] && logger_xen "DEP_STATE has been set to: \"$DEP_STATE\". the current CHILDREN_LIST is: \"$CHILDREN_LIST\" and the PARENT is: \"$PARENT\"." 168 | ;; 169 | 170 | space_for_backup_check) 171 | [[ $DEBUG = "ALL" || $DEBUG =~ .*space_for_backup_check.* ]] && logger_xen "Func space_for_backup_check has been invoked." 172 | DISKS_SIZE=0 173 | for DISK in $( $xencmd vm-disk-list uuid=$1 | grep virtual-size | awk '{print $4}' ); do 174 | [[ $DEBUG = "ALL" || $DEBUG =~ .*space_for_backup_check.* ]] && logger_xen "Disk with the size of \"$DISK\", was found for VM \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\"." 175 | DISKS_SIZE=$(( $DISKS_SIZE + $DISK )) 176 | done 177 | logger_xen "Total disks size is: \"$DISKS_SIZE\" for \"$VM_NAME_FROM_UUID\"." 178 | FREE_SPACE="$( df $BackupLocation | grep $BackupLocation | awk '{print $3}' )" 179 | if [[ -n $FREE_SPACE ]] ; then 180 | [[ $DEBUG = "ALL" || $DEBUG =~ .*space_for_backup_check.* ]] && logger_xen "FREE_SPACE="$( df $BackupLocation | grep $BackupLocation | awk '{print $3}' )"" 181 | [[ $DEBUG = "ALL" || $DEBUG =~ .*space_for_backup_check.* ]] && logger_xen "BackupLocation is: $BackupLocation" 182 | FREE_SPACE_IN_BYTES=$(( $FREE_SPACE * 1024 )) 183 | if [[ $(( $FREE_SPACE_IN_BYTES - $DISKS_SIZE * 2 )) -le "1000000000" ]]; then 184 | logger_xen "Disqualified VM \"$VM_NAME_FROM_UUID\" form export, because the VM aggregate disk size is $(( $DISKS_SIZE / 1000000000 ))G and had we continued with this export, less than 10G would be left on the backup location." "expose" "Exception - Disqualification" 185 | logger_xen "" # log formatting 186 | logger_xen "" # log formatting 187 | continue 188 | else 189 | [[ $DEBUG = "ALL" || $DEBUG =~ .*space_for_backup_check.* ]] && logger_xen "There was enough space for the backup :)" 190 | #logger_xen "" # log formatting 191 | fi 192 | else 193 | [[ $CHECK_FREE_SPACE = "yes" ]] && CHECK_FREE_SPACE="no" && logger_xen "" && logger_xen "Assessment of the FREE_SPACE parameter failed for backup location \"$BackupLocation\". You may disable this check in the settings file.\\nNote: This is a known issue when the backup location is a subdirectory in the mounted share." "expose" && logger_xen "" 194 | fi 195 | ;; 196 | 197 | *) logger_xen "Incorrect use of xe func" 198 | esac 199 | } 200 | 201 | backup_func() 202 | { 203 | logger_xen "Backup func has been invoked for \"$1\"." 204 | VM_TO_BACKUP="$1" 205 | xen_xe_func "$VM_TO_BACKUP" "uuid_2_name" 206 | xen_xe_func "$VM_TO_BACKUP" "space_for_backup_check" 207 | xen_xe_func "$VM_TO_BACKUP" "org_state" 208 | BACKUP_FILE_AND_LOCAL_LONG="${BackupLocation}/${VM_NAME_FROM_UUID}- ${1}.xva" 209 | BACKUP_FILE_AND_LOCAL_LONG="${BACKUP_FILE_AND_LOCAL_LONG// /_}" 210 | [[ -e "$BACKUP_FILE_AND_LOCAL_LONG" ]] && mv "$BACKUP_FILE_AND_LOCAL_LONG" "$BACKUP_FILE_AND_LOCAL_LONG.org" && logger_xen "Moved old backup to temp location." 211 | [[ $POWERSTATE = "running" ]] && xen_xe_func "$1" "shutdown" 212 | logger_xen "Now exporting \"$VM_TO_BACKUP\"." 213 | xen_xe_func "$VM_TO_BACKUP" "export" 214 | if [[ $ORG_STATE = "running" && "$2" != "child" ]];then 215 | logger_xen "Now starting up $1, because ORG_STATE was $ORG_STATE" 216 | xen_xe_func "$1" "start" 217 | logger_xen "Giving $WARM_UP_DELAY seconds so that $1 finishes warming up" 218 | sleep $WARM_UP_DELAY 219 | fi 220 | [[ $2 = "child" ]] && logger_xen "This VM \"$VM_NAME_FROM_UUID\" is a CHILD, will not start it until PARENT is done." 221 | [[ $EXPORT = "OK" && -e $BACKUP_FILE_AND_LOCAL_LONG.org ]] && rm "$BACKUP_FILE_AND_LOCAL_LONG.org" -f && logger_xen "Deleted old backup for \"$VM_NAME_FROM_UUID\" with UUID of: \"$1\" as new one is OK." 222 | } 223 | ##################ENGINE############################################# 224 | logger_xen "Welcome to the Xen-pocalypse backup script." 225 | logger_xen "" # log formatting 226 | 227 | if [[ -z "$@" ]]; then 228 | logger_xen "You must pass first argument settings file and second argument backup TAG or file to work on." "expose" 229 | exit 2 230 | fi 231 | 232 | SETTINGS_FILE="$1" 233 | [[ ! -e $SETTINGS_FILE ]] && logger_xen "Settings file, $SETTINGS_FILE not found" && exit 2 234 | if [[ -n $( head -1 $SETTINGS_FILE | grep "settings file for the Xen-pocalypse" ) ]]; then 235 | source $SETTINGS_FILE && logger_xen "Settings file header found in \"$SETTINGS_FILE\", so it was sourced." 236 | [[ $DEBUG != "0" ]] && logger_xen "The DEBUG paramter is enabled and the following flags are used: \"$DEBUG\"" 237 | else 238 | logger_xen "The appropriate header, was NOT found in the designated settings file. The so called settings file $SETTINGS_FILE was NOT sourced and Xen-pocalypse will now exit." "expose" 239 | echo "The appropriate header, was NOT found in the designated settings file. The so called settings file $SETTINGS_FILE was NOT sourced and Xen-pocalypse will now exit." 240 | exit 2 241 | fi 242 | if [[ -n "$2" ]] ;then 243 | logger_xen "" # log formatting 244 | SECOND_PARAM="$2" 245 | else 246 | logger_xen "Second argument cannot be empty!" "expose" 247 | exit 2 248 | fi 249 | 250 | Email_func "$Email_VAR" "Started" 251 | 252 | if [[ $DEBUG = "0" ]]; then 253 | WARM_UP_DELAY=60 254 | else 255 | WARM_UP_DELAY=5 256 | fi 257 | 258 | ###Target location preflight checks 259 | #massaging BackupLocation, so that it doesn't have trailing slashes 260 | BackupLocation=${BackupLocation%/}; [[ $DEBUG = "ALL" || $DEBUG =~ .*backuplocation.* ]] && logger_xen "BackupLocation trailing slash have been removed." 261 | #warmup backup location 262 | dd if=/dev/zero of=$BackupLocation/testfile.blob bs=1M count=1 &> /dev/null 263 | touch $BackupLocation/testfile.blob &> /dev/null 264 | rm -f $BackupLocation/testfile.blob &> /dev/null 265 | #end of warmup 266 | touch $BackupLocation/testfile.blob &> /dev/null 267 | if [[ "$?" -eq 0 ]] ; then 268 | [[ $DEBUG = "ALL" || $DEBUG =~ .*backuplocation.* ]] && logger_xen "Trying to create a simple file was successful." 269 | [[ $CHECK_FREE_SPACE = "yes" ]] && [[ $DEBUG = "ALL" || $DEBUG =~ .*backuplocation.* ]] && logger_xen "The CHECK_FREE_SPACE is set to \"$CHECK_FREE_SPACE\", so will try to create a 10G file." 270 | [[ $CHECK_FREE_SPACE = "yes" ]] && dd if=/dev/zero of=$BackupLocation/testfile.blob bs=1 seek=10240000000 count=1 &> /dev/null 271 | if [[ "$?" -eq 0 ]] ; then 272 | [[ $DEBUG = "ALL" || $DEBUG =~ .*backuplocation.* ]] && logger_xen "Was able to create a 10G file." 273 | rm -f $BackupLocation/testfile.blob &> /dev/null 274 | if [[ "$?" -eq 0 ]] ; then 275 | [[ $DEBUG = "ALL" || $DEBUG =~ .*backuplocation.* ]] && logger_xen "Was able to delete test file." 276 | else 277 | logger_xen "Was not able to delete test file??" "expose" "Backup location - Abort!" 278 | fi 279 | else 280 | logger_xen "Was not able to create a 10G file, so aborting backup run.\\nNote: This behavior can be changed in the settings file by changing the CHECK_FREE_SPACE parameter to \"no\"." "expose" "Backup location - Abort!" 281 | exit 2 282 | fi 283 | else 284 | logger_xen "Was unable to create even the simplest form of a file to the backup location \"$BackupLocation\", so backup run has been aborted." "expose" "Backup location - Abort!" 285 | exit 2 286 | fi 287 | 288 | #VM list arbitrator 289 | if [[ $LIST_METHOD = "FILE" ]]; then 290 | logger_xen "VM List method in the settings file was \"$LIST_METHOD\", so Xen-pocalypse will now treat the second argument \"$2\" as a file." 291 | FILELIST="$2" 292 | if [[ ! -e $FILELIST ]]; then 293 | logger_xen "Filelist \"$FILELIST\" not found. Make sure the file is accessible." "expose" 294 | exit 2 295 | fi 296 | if [[ -z "$( cat $FILELIST )" ]]; then 297 | logger_xen "Filelist \"$2\" cannot be empty!" "expose" 298 | exit 2 299 | fi 300 | if [[ -n $( head -1 $FILELIST | grep "settings file for the Xen-pocalypse" ) ]]; then 301 | logger_xen "You are trying to use the settings file as the Filelist. Stop it...\n First argument is the settings file, second is the file list." "expose" 302 | exit 2 303 | fi 304 | logger_xen "VM List $FILELIST found and had content. Will now process VM list from \"$FILELIST\"."; logger_xen "" # log formatting" 305 | VM_LIST="$( cat $FILELIST )" 306 | for VM_NAME in $VM_LIST; do 307 | xen_xe_func "$VM_NAME" "vm-existance" 308 | xen_xe_func "$VM_NAME" "name_2_uuid" 309 | VM_LIST_UUID="$VM_LIST_UUID $VM_UUID" 310 | [[ $DEBUG != "0" ]] && logger_xen "the current VM_LIST_UUID is: \"$VM_LIST_UUID\"" 311 | done 312 | 313 | elif [[ $LIST_METHOD = "TAGs" ]]; then 314 | logger_xen "VM List method in the settings file was \"$LIST_METHOD\", so Xen-pocalypse will now treat the second argument \"$2\" as a TAG." 315 | TAG="$2" 316 | VM_LIST="$( $xencmd vm-list other-config:XenCenter.CustomFields.BackupTAG=$TAG params=uuid | grep uuid| awk '{print $5}' )" 317 | VM_LIST_UUID="$VM_LIST" 318 | else 319 | logger_xen "No recognized LIST_METHOD was given. The options are: FILE or TAGs. Please configure the settings file correctly and try again." "expose" 320 | exit 2 321 | fi 322 | logger_xen "" 323 | logger_xen "" 324 | 325 | 326 | 327 | #The work. 328 | for VM in $VM_LIST_UUID; do 329 | logger_xen "Working on \"$VM\"." 330 | xen_xe_func "$VM" "vm_properties" 331 | if [[ $DEP_STATE = "dep_parent" ]]; then 332 | logger_xen "Found that \"$VM_NAME_FROM_UUID\" is a Parent for \"$CHILDREN_LIST\". Will now backup the children." 333 | for CHILD in $CHILDREN_LIST_UUID; do 334 | logger_xen "" # log formatting 335 | logger_xen "Backing up CHILD \"$CHILD\" for PARENT $VM_NAME_FROM_UUID." 336 | backup_func "$CHILD" "child" 337 | logger_xen "" # log formatting 338 | done 339 | logger_xen "Done backing-up the children and will now backup the PARENT \"$VM_NAME_FROM_UUID\"" 340 | backup_func "$VM" 341 | logger_xen "Now that PARENT \"$VM_NAME_FROM_UUID\" with UUID of: \"$VM\" has been backed-up, will now start children: $CHILDREN_LIST." 342 | for CHILD in $CHILDREN_LIST; do 343 | xen_xe_func "$CHILD" "start" "child" 344 | done 345 | logger_xen "Done starting all children for \"$VM_NAME_FROM_UUID\" with UUID of: \"$VM\"" 346 | logger_xen "" # log formatting 347 | elif [[ $DEP_STATE = "dep_child" ]]; then 348 | logger_xen "Found this VM \"$VM_NAME_FROM_UUID\" to be a CHILD of \"$PARENT\", so skipping it for now." 349 | logger_xen "" # log formatting 350 | fi 351 | [[ $DEP_STATE = "null" ]] && backup_func "$VM" 352 | logger_xen "" # log formatting 353 | logger_xen "" # log formatting 354 | done 355 | 356 | #Yey Done 357 | logger_xen "Backup script has finished its run and will now Email the report." 358 | if [[ $LIST_METHOD = "TAGs" ]]; then 359 | Email_func "$Email_VAR" "Report for $TAG" 360 | else 361 | Email_func "$Email_VAR" "Report" 362 | fi 363 | --------------------------------------------------------------------------------