Snapshotting an instance will create a Glance image of the instance at the point in time the snapshot was taken. This image can then be used to deploy additional instances of a given application, or as a bootable backup of the instance.
In order to create a snapshot of an instance, you require the following information:
openstack
command-line clientopenrc
file containing appropriate credentialsThe following commands are used to create an instance snapshot:
openstack image list -c Name -c Status
This will bring back a list of images like the following:
openstack server list -c Name -c Status
This gives an output like the following:
openstack server image create --name cookbook.test_snapshot-$(date +"%FT%H%M%S") cookbook.test
This brings an output like the following:
openstack image list
This gives an output that will show our snapshotted image:
Instance snapshots create a Glance image of the running instance. The snapshot can be used for backup, redistribution, or part of a continuous deployment pipeline as a build artifact. The images created with openstack server image create --name [snapshot_name] [instance]
are bootable. You have a large degree of flexibility in how they are used.
Instance snapshots are rather powerful. While a full exploration of the possibilities are beyond the scope of this book, the following example shows you what can be achieved using this feature: an easy way to back up all running instances.
To snapshot every instance, use the following command:
for instance in $(openstack server list -f value -c ID); do { openstack server image create --name "${instance}"-$(date +"%FT%H%M%S") ${instance} }; done
18.218.238.134