How To: Live Backup VM and Restore VM on Nodegrid

How To: Live Backup VM and Restore VM on Nodegrid

There are several ways to backup virtual machines and as Nodegrid becomes a popular choice for hosting virtual machines in the data center or at the edge running on our Nodegrid Service Routers, administrators need a way to backup and restore the VM.

Nodegrid does not backup virtual machines when your run a Nodegrid Backup, therefore, you must backup virtual machines on your own with built-in command line utilities or third-party software.

This article will show how to backup a running VM live and then restore it in case of disaster.  The method shown below relies on default values for backup and will 'push' the backup to same location that the image is running at.  For more control of which disks to backup and type of backup, refer to https://libvirt.org/formatbackup.html.

As of Nodegrid OS 5.10.1, there is no way to backup via the UI, instead this must be done as root user.

Become Root

To become root, login as Nodegrid admin that has sudo access.  Connect to the console or ssh.  If your admin user is in a CLI shell on startup, use the 'shell' command to get to a regular Linux shell and then use sudo command to become root.

Following commands will login via ssh to the Nodegrid, become root from CLI shell, and verify that root access was obtained.
shell sudo su -
whoami



Backup Virtual Machine

Find the VM you want to backup, use virsh command to list the running virtual machines and make a note of the "Name", this is also known as the Domain.

Run command:
virsh list


In this example, the VM we want to backup is ubuntu22.04-2023-6-2.  The backup will be stored in same location as the image, by default /var/lib/libvirt/images, begin the backup with following command:
virsh backup-begin ubuntu22.04-2023-6-2


Monitor the backup with virsh domjobinfo command, check Job Type, when it is "None", job is not running, validate completed status with --completed option to the virsh command:
virsh domjobinfo ubuntu22.04-2023-6-2


Check the backup images, there will be more than one if you more than one virtual disk, in the image below, the backup is the qcow2 file with a number appended at the end.



Backup the VM Configuration

Finally, last step is to backup the VM configuration so that you can restore it on this same device.  If you restore or migrate to a different device, you may need to rebuild attached NICs or other devices.  Run virsh dumpxml for the VM and redirect the output to a file:
virsh dumpxml ubuntu22.04-2023-6-2 > ubuntu22.04-2023-6-2.backup.xml
Save or move the backup image and the dumped XML to your backup location or server.

Restore Virtual Machine from Live Backup

Restoring involves placing the backup image to the images location for your VMs and updating the saved XML from the previous step with the location of the restore image.  In this example, I renamed the image to /var/lib/libvirt/images/ubuntu-restored.qcow2.  Run these commands as root user.

Edit the xml file ubuntu22.04-2023-6-2.backup.xml and update the line for the disk element and change the source to match the location of the image.  For example, from this excerpt below, the line in red is what needs to be edited, and I changed the file value to match the location of my restored image

    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/ubuntu22-restored.qcow2' index='2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </disk>

Then run the command virsh define /path/to/xml replacing the the path with the location of the XML you uploaded
virsh define /home/admin/ubuntu22.04-2023-6-2.backup.xml


Now start the VM, you can do this via the UI or from virsh.  With virsh, use virsh list --all to see the new VM you restored.  Then use the VM name to start with virsh start command.  Verify the VM is running with virsh list
virsh list --all
virsh start ubuntu22.04-2023-6-2
virsh list



Done.

Reference


All of this information was gathered from libvirt documentation site, refer to the links above for more information.



    • Related Articles

    • Restoring backups to a Nodegrid Appliance

      Nodegrid restore is an easy way to restore backups from stored configuration backups  Follow these steps to restore backup to the Nodegrid 1. Login as admin and navigate to System::Toolkit 2. Select Apply Settings 3. Now one has to choose where to ...
    • Improved Nodegrid UI for backup

      New for Nodegrid 6.0, the user interface for Nodegrid Save Settings (backup) is improved. Previously, the backup option from System::Toolkit::Save_Settings would save backups to the main disk to the root location /backup when you select "Local ...
    • Local Virtual Machines VM's can't be accessed from ZPE Cloud - Workaround

      Unable to launch Local VM from ZPE Cloud portal. ZPE Cloud Portal Access: Login into the ZPE cloud interface Navigate to Applications :: Virtual Machines :: Virtual Machines VM - Workaround The VNC console will keep on spinning trying to connect. ...
    • How to: Backup a Nodegrid device using ZPE Cloud

      ZPE cloud enables managing on-demand and scheduled backups of your Nodegrid devices. Login to ZPE Cloud Go to Devices :: Enrolled Select the devices you want to backup and then click Backup. You can backup multiples devices at once. Select the File ...
    • How to Save and Restore backup configuration from/to Nodegrid

      To Save the current configuration of your Nodegrid, follow the steps below: WebUI 1. Go to System, Toolkit, and click on Save Settings icon. 2. Select the option where you want to save the configuration:        a. Local System: enter the file name ...