Backing up your VM: Difference between revisions

(First substantial draft of Backing-up persistent VMs, much editing still required.)
Line 4: Line 4:


==Persistent VMs==
==Persistent VMs==
Persistent VMs are designed to boot from volumes (see [[OpenStack#Booting_from_a_Volume| booting from a volume]]) and as such to back-up a persistent VM a copy can be created of the volume(s) the VM has attached to it. The best way to create a copy of a volume for backup purposes is to create an image from that volume. An image can be downloaded and reused to create multiple new VMs, can be accessed by VirtualBox on your Desktop or laptop, and uploaded to other clouds.
Persistent VMs are designed to boot from volumes (see [[OpenStack#Booting_from_a_Volume| booting from a volume]]) thus creating a copy of the volume(s) the VM has attached to it will produce a backup. However this would not preserver things like VM flavor, public IP, and security rules. The best way to create a copy of a volume for backup purposes is to create an image from that volume. An image can be [[OpenStack#Downloading_an_Image|downloaded]] and reused to create multiple new VMs, can be [[OpenStack#Creating_a_VirtualBox_VM_from_a_Cloud_Image|accessed by VirtualBox]] on your Desktop or laptop, and [[OpenStack#Uploading_an_Image|uploaded]] to other clouds.


To be able to create an image from a volume, that volume must be detached from the VM. In addition, if the volume is the root volume of the VM it can not be detached unless the VM is deleted. If you are sure that when you created the VM you did not check the box "Delete Volume on Instance Delete" then you can delete your VM knowing you will not loose any data. However, if you are unsure if you checked this box or not OpenStack unfortunately doesn't tell you if this box was checked when you created the VM after the fact. One trick which maybe useful for getting around this, is to create a snapshot of the volume provided you have a storage quota which allows it (Snapshots count towards your storage quota). Since volumes can not be deleted if there is a volume snapshot created from them, when you delete the VM the volume will not be deleted even if you checked this box.
To be able to create an image from a volume, that volume must be detached from the VM. In addition, if the volume is the root volume of the VM it can not be detached unless the VM is deleted. If you are sure that when you created the VM you did not check the box "Delete Volume on Instance Delete" then you can delete your VM knowing you will not loose any data. However, if you are unsure if you checked this box OpenStack, unfortunately, doesn't tell you if this box was checked when you created a VM. One trick which maybe useful for getting around this, is to create a snapshot of the volume provided you have a storage quota which allows it (Snapshots count towards your storage quota). Since volumes can not be deleted if there is a volume snapshot created from them, when you delete the VM the volume will not be deleted even if you checked the box.


At this point all the volumes you wish to create images from should be in the "Available" state. From the drop down menu for the volume you wish to create an image of, select 'Upload to Image'. Select the 'QCOW2' disk format and give your image a name.
At this point all the volumes you wish to create images of should be in the "Available" state. To create an image from a volume, select 'Upload to Image' from the drop down menu for the volume. Select the 'QCOW2' disk format and give your image a name. There are several formats for disk images but QCOW2 works well with OpenStack and typically does not take up as much space as "Raw" images. Other formats "vmdk" and "vdi" can be useful when working with other virtualization tools such as VirtualBox.


Once you have created images of all the volumes you wish to backup you can then re-create your VM booting from the original VM's root volume and attaching any additional volumes you may have had attached to the original VM.
Once you have created images of all the volumes you wish to backup you can then re-create your VM booting from the original VM's root volume and attaching any additional volumes you may have had attached to the original VM.
cc_staff
1,486

edits