Creating Backups & Clones Of Running Virtual Machines (No Downtime) With LVM Snapshots

use LVM volumes for your VirtualBox VMs This lesson shows using LVM snapshots to create backups and clones of running VirtualBox VMs without downtime

1 Preliminary Note

Installed VirtualBox on a headless server use phpvirtualbox as the VirtualBox GUI here. use the original VirtualBox GUI then only it will be perfect.

Running virtual machine named vm10 located on the LVM volume /dev/vg0/vm10.

logged in as root

sudo su

Should run as root user

2 Create A Backup Of A Running VM With LVM Snapshots

create a backup of the running virtual machine vm10 Snapshots can be smaller than the original volume – 512MB

lvcreate -L5G -s -n vm10_snap /dev/vg0/vm10

use dd to read the contents from the snapshot and pipe it to gzip to create a gzipped backup image in the directory

dd if=/dev/vg0/vm10_snap bs=64k | gzip -c > /backup/vm10.img.gz

your backup of vm10 is now located in /backup/vm10.img.gz.

remove the LVM snapshot

lvremove -f /dev/vg0/vm10_snap

3 Restore From A Backup/Clone From A Backup

cloning is essentially the same how to create a clone called vm11 from the backup we’ve just created

create an LVM volume of the same size as the original LVM volume

lvcreate -L20G -n vm11 vg0

Restore the backup of vm10 to the local volume

gunzip -c /backup/vm10.img.gz | dd of=/dev/vg0/vm11 bs=64k

create a .vmdk file for


now it can be use it with VirtualBox

cd /home/vbox
VBoxManage internalcommands createrawvmdk -filename vm11.vmdk -rawdisk /dev/vg0/vm11
chown vbox:vbox vm11.vmdk