general:xenserver:xenserver
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
general:xenserver:xenserver [2021/08/25 07:45] – created sunkan | general:xenserver:xenserver [2021/08/25 07:53] (current) – [Snapshot and copy VM] sunkan | ||
---|---|---|---|
Line 4: | Line 4: | ||
Turn on autostart | Turn on autostart | ||
- | < | + | < |
#!/bin/sh | #!/bin/sh | ||
Line 13: | Line 13: | ||
Turn off autostart | Turn off autostart | ||
- | < | + | < |
#!/bin/sh | #!/bin/sh | ||
Line 21: | Line 21: | ||
</ | </ | ||
+ | ===== Backup metadata to other storage ===== | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | STORAGE_SR_NAME="/ | ||
+ | |||
+ | if [ -e / | ||
+ | if [ "$(cat / | ||
+ | sruuid=$( xe sr-list name-label=${STORAGE_SR_NAME} --minimal ) | ||
+ | "/ | ||
+ | EXITVALUE=$? | ||
+ | if [ $EXITVALUE != 0 ]; then | ||
+ | / | ||
+ | fi | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | exit 0 | ||
+ | </ | ||
+ | |||
+ | ===== Snapshot and copy VM ===== | ||
+ | |||
+ | Snapshot and copy VM (possibly to other storage) | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | set -e | ||
+ | |||
+ | VMToCopy= | ||
+ | NewName=${VMToCopy}-copy | ||
+ | DestStorageName=" | ||
+ | |||
+ | oldcopyid=$( xe vm-list name-label=$NewName --minimal ) | ||
+ | #echo $oldcopyid | ||
+ | |||
+ | snapid=$( xe vm-snapshot name-label=$VMToCopy new-name-label=$NewName-$datestr ) | ||
+ | #echo "$? ID: $snapid" | ||
+ | |||
+ | datestr=$( date +%Y-%m-%d_%R_%Z ) | ||
+ | |||
+ | templateid=$( xe snapshot-copy new-name-label=$NewName uuid=$snapid sr-uuid=$( xe sr-list name-label=" | ||
+ | #echo "$? ID: $templateid" | ||
+ | |||
+ | xe template-param-set uuid=$templateid is-a-template=false | ||
+ | #echo "$? ID: $templateid" | ||
+ | |||
+ | xe snapshot-uninstall uuid=$snapid force=true > /dev/null | ||
+ | #echo " | ||
+ | |||
+ | xe vm-param-remove uuid=$templateid param-name=other-config param-key=auto_poweron | ||
+ | xe vm-param-set uuid=$templateid name-description=" | ||
+ | #echo " | ||
+ | |||
+ | xe vm-reset-powerstate uuid=$templateid force=true | ||
+ | #echo " | ||
+ | |||
+ | xe vm-uninstall vm=$oldcopyid force=true > /dev/null | ||
+ | |||
+ | </ |
general/xenserver/xenserver.txt · Last modified: 2021/08/25 07:53 by sunkan