0

I want to backup a few virtual machines to a backup server. Here're the backup steps.

suspend a virtual machine
create a snapshot of the virtual machine using lvcreate -s
resume a virtual machine
dd if=/virtual_machine_path | lzop > /temp/backup.lzo
rsync /temp/backup.lzo -e "ssh " 1.2.3.4:/backup_path/

However, the hypervisor server doesn't have enough hard disk space to create a snapshot in step 2. Is there a way to create a logical volume snapshot to a remote server?

mdpc
  • 11,698
  • 28
  • 51
  • 65
Purres
  • 239
  • 1
  • 4
  • 18
  • Which Hypervisor are you using? – ewwhite Aug 20 '14 at 22:19
  • I'm using KVM and libvirt. – Purres Aug 20 '14 at 22:21
  • I don't suppose adding more storage to your VG is an option? – Zoredache Aug 20 '14 at 23:15
  • Each virtual machine has a different size. If a newly created virtual machine has a very large disk space, then a lvm snapshot would cause a disk space shortage, no matter the storage I add. – Purres Aug 20 '14 at 23:44
  • LVM snapshots only use space for any changes, taking a snapshot of a 500GB volume does not require 500GB for the snapshot unless 500GB of writes happen before you're done with the snapshot. –  Aug 21 '14 at 00:16
  • That's right. I couldn't predict how many changes would happen after a snapshot is created. If making a snapshot volume too small, it would be filled quick and become invalid. If making a snapshot volume auto extends, it would take more disk space. – Purres Aug 21 '14 at 00:29
  • Are you not using thin provisioning in your LVM volumes? – Michael Hampton Aug 21 '14 at 01:26
  • No, I'm not using thin provisioning. – Purres Aug 21 '14 at 19:05

1 Answers1

0

You can do this with netcat.

dd if=/virtual_machine_path | gzip -o - | nc 1.2.3.4 1234

Then on 1.2.34, do

nc -l 1234 > backup.gz
devicenull
  • 5,572
  • 1
  • 25
  • 31
  • I can only backup a virtual machine from its snapshot. Is there a way to combine netcat and lvcreate -s ? – Purres Aug 23 '14 at 00:56
  • You have to create the snapshot regardless, but the snapshot is just another LVM logical volume so you can use the path to it directly. – devicenull Aug 23 '14 at 00:57
  • How to create the snapshot logical volume to a remote server? – Purres Aug 23 '14 at 01:21