Created
September 14, 2010 20:18
Live XCP host backups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
DST_PATH="${DST_PATH:-/tmp}" | |
backup() { | |
uuid="$1" | |
label_name=$( xe vm-list uuid="$uuid" | grep 'name-label' | cut -b 24- ) | |
snapshot_uuid=$( xe vm-snapshot vm="$uuid" new-name-label=backup_vm ) | |
xe template-param-set is-a-template=false ha-always-run=false uuid="$snapshot_uuid" | |
filename="$DST_PATH/$( date +%Y-%m-%d )-$uuid.xva" | |
xe vm-export vm="$snapshot_uuid" filename="$filename" | |
xe vm-uninstall uuid="$snapshot_uuid" force=true | |
} | |
backup_all() { | |
options="vm-list is-control-domain=false is-a-template=false is-a-snapshot=false" | |
for uuid in $( xe $options | grep 'uuid' | awk -F': ' '{ print $2 }' ); do | |
backup "$uuid" | |
done | |
} | |
if [[ -z "$1" ]]; then | |
echo "Usage: $0 (<UUID>|all)" | |
exit 2 | |
fi | |
if [[ "$1" = "all" ]]; then | |
backup_all | |
else | |
backup "$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment