How To Backup Linux VM?

chspyder

Cadet
Joined
Oct 16, 2021
Messages
9
I have read many many threads and found tons of solutions for backing up the data file systems, and I thank every person that has posted this, But I want to specifically backup my VM volumes (Ubuntu, and 2 Linux Mint) I feel so stupid as I don't have a good way to completely backup each VM, yes I have snapshots and I have tried time and time again to replicate them to a backup drive (thinking this is a good solution) with no luck. Cloud sync... and no snapshots show, or volumes. It is almost like the VM volumes are not getting backed up. I have tried the \.zfs\snapshot and its blank!
I am really giving up and I know one of you brilliant folks can point me in the correct direction for this.

Thanks!
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
You need to use zfs send to replicate volumes. The .zfs folder is only for datasets.

Code:
zfs snapshot <pool-name>/path/to/vm-zvol@20220830
zfs send <pool-name>/path/to/vm-zvol@20220830 > /mnt/<pool-name>/some/storage/space/vm-zvol-20220830.img


That saves the VM volume to a file somewhere else in the pool. The easiest solution is to have a backup system using ZFS, too. And simply replicate the entire dataset and volumes recursively.

HTH,
Patrick
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
One comment about VM & zVol backups. To get absolutely clean and guaranteed to be usable as a recoverable OS at the time the snapshot was taken, you need to shut down the VM's OS before the snapshot. The actual snapshot takes mere seconds, and then you can boot up your VM's OS again. This method makes as clean a copy as possible.

Even though shutting down the VM's OS is annoying, as Ripley said: "It's the only way to be sure."

Of course, you can stagger the backups. Perhaps performing the VM shutdown type backup once a month. Then the others without the shutdown.
 
Top