{"id":322,"date":"2010-12-09T23:05:02","date_gmt":"2010-12-09T23:05:02","guid":{"rendered":"http:\/\/psyphi.net\/blog\/?p=322"},"modified":"2010-12-09T23:05:02","modified_gmt":"2010-12-09T23:05:02","slug":"automated-basic-xen-snapshots","status":"publish","type":"post","link":"https:\/\/psyphi.net\/blog\/2010\/12\/automated-basic-xen-snapshots\/","title":{"rendered":"Automated basic Xen snapshots"},"content":{"rendered":"<p>With a little bit of shell-scripting I made this. It runs on a dom0 and scans through virtual machines running on a cluster, requesting snapshots of each one. You may want to use vm-snapshot-with-quiesce if it&#8217;s supported by xen-tools on your domU machines.<\/p>\n<p><code>\u00ef\u00bb\u00bf\u00ef\u00bb\u00bf\u00ef\u00bb\u00bffor i in `xe vm-list params=name-label | grep name | awk '{print $NF}' | xargs echo`; do echo $i; xe vm-snapshot vm=$i new-name-label=\"$i-`date +'%Y-%m-%dT%H:%M:%S'`\"; done<\/code><\/p>\n<p>If you cron the above script every day then after a few days you may want to start deleting the oldest snapshots:<\/p>\n<p><code>\u00ef\u00bb\u00bffor i in `xe vm-list params=name-label | grep name | awk '{print $NF}'`; do snapshot=`xe vm-list name-label=$i params=snapshots | awk '{print $NF}'`; echo \"$i earliest snapshot is $snapshot\"; if [ \"$snapshot\" ]; then xe vm-uninstall vm=$snapshot force=true; fi; done<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With a little bit of shell-scripting I made this. It runs on a dom0 and scans through virtual machines running on a cluster, requesting snapshots of each one. You may want to use vm-snapshot-with-quiesce if it&#8217;s supported by xen-tools on your domU machines. \u00ef\u00bb\u00bf\u00ef\u00bb\u00bf\u00ef\u00bb\u00bffor i in `xe vm-list params=name-label | grep name | awk &#8216;{print &hellip; <a href=\"https:\/\/psyphi.net\/blog\/2010\/12\/automated-basic-xen-snapshots\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Automated basic Xen snapshots&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[17,18],"tags":[589,588,1083,587],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry","category-sysadmin","category-virtualisation","tag-backups","tag-snapshots","tag-virtualisation","tag-xen"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":4,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"predecessor-version":[{"id":327,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/322\/revisions\/327"}],"wp:attachment":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}