Forum Discussion
How do I backup my full virtual machine?
If you need a powerful open-source tool for backing up virtual machines, I highly recommend Clonezilla! It supports full disk image backups and can restore data quickly, making it the ultimate safeguard for data security. However, manually operating Clonezilla can be a bit complex, so I wrote an automation script to simplify the process.
1. Download the Clonezilla image and create a bootable USB drive (e.g., using Rufus).
2. Boot Clonezilla, select "Device to Image" mode, and back up the virtual machine disk to external storage.
3. To restore, select "Image to Device" mode for quick recovery.
I wrote a script to automatically mount the virtual machine disk and use Clonezilla's command-line tools for backup. Here's an example script to backup virtual machine instance:
#!/bin/bash
VM_DISK="/path/to/vm_disk.vdi"
BACKUP_DIR="/mnt/backup"
CLONEZILLA_ISO="/path/to/clonezilla-live.iso"
sudo mount -o loop "$VM_DISK" /mnt/vm
sudo clonezilla -b -s /mnt/vm -t /mnt/backup -i "$CLONEZILLA_ISO"
sudo umount /mnt/vm
echo "Backup completed: $BACKUP_DIR/vm_disk_$(date +%Y%m%d) . img"