KVM - QEMU backup

mikeborschow

New Member
Jul 9, 2008
29
0
1
I am using vzdump to backup containers - works well. Is there a smart utility that is similar to vzdump to handle the kvm side of the system for backup? If not, has anybody put together good scripts for backup and restore on the KVM side.

Also was wondering if the KVM files are in LVM so that they could be snapshotted?
 
I am using vzdump to backup containers - works well. Is there a smart utility that is similar to vzdump to handle the kvm side of the system for backup? If not, has anybody put together good scripts for backup and restore on the KVM side.

We are working on that. V1.0 will support that.

Also was wondering if the KVM files are in LVM so that they could be snapshotted?

Yes
 
Just curious ... as I've already put 0.9 into production use (light use at the moment) ... will 1.0 be an upgrade that will allow me to keep the current system running, or will it be a new bare metal install?
 
I don't know just how wrong this is, but I simply backed up /etc/qemu-server and /var/lib/vz and I could migrate servers without problems. These were all KVMs though.
 
I don't know just how wrong this is, but I simply backed up /etc/qemu-server and /var/lib/vz and I could migrate servers without problems. These were all KVMs though.
That's what I'm doing as well, however, it takes a while and I'm stopping the machines prior to the backup because I don't know how/if LVM snapshot might be in play???
 
You can use LVM2 snapshots to back things up while keeping them running.

Code:
lvcreate -s -L 2g -n backupsnapshot /dev/pve/data
mount /dev/mapper/pve-backupsnapshot /backupsnapshot
...(do your backups here)...
umount /backupsnapshot
lvremove -f /dev/pve/backupsnapshot
 
You can use LVM2 snapshots to back things up while keeping them running.

Code:
lvcreate -s -L 2g -n backupsnapshot /dev/pve/data
mount /dev/mapper/pve-backupsnapshot /backupsnapshot
...(do your backups here)...
umount /backupsnapshot
lvremove -f /dev/pve/backupsnapshot

Okay, first, thanks! Now, for my slow to learn brain, could you please advise what goes in "do your backups here"... this is the script that I currently run to back up everything... It's been many moon's since I worked in linux, so please be kind... /drive2 is a actually a 2nd hard drive on the machine and I'm using 7z (although I don't have to) for compression..:

#
#
# --- backup of virtual containers & machines ---
#
#
dend=`date +%Y%m%d-%H%M%S-backup`
dname1=`date +%Y%m%d-%H%M-images-backup`
ddir=/drive2/backups/$dend
mkdir $ddir
vzdump --dumpdir $ddir --snapshot --all
mkdir $ddir/kvm
7z a -mx=9 $ddir/kvm/$dname1 /var/lib/vz/images/*
cp /etc/qemu-server/* $ddir/kvm/
exit 0

Any help is kindly accepted. -m
 
Your script looks nice, just use my procedure wrapped around your 7zip command and 7zip from /backupsnapshot/images rather than 7zipping from /var/lib/vz/images. What I wrote earlier is really just for backing up KVMs since vzdump --snapshot already does an LVM snapshot and spits out a nice file for you.
 
Your script looks nice, just use my procedure wrapped around your 7zip command and 7zip from /backupsnapshot/images rather than 7zipping from /var/lib/vz/images. What I wrote earlier is really just for backing up KVMs since vzdump --snapshot already does an LVM snapshot and spits out a nice file for you.

Thanks. Will try it and let you know how it goes
 
I know it's been a while since we visited this... but I'm still not doing something right.

#
#
# --- backup of virtual containers ---
#
#
dend=`date +%Y%m%d-%H%M%S-backup`
dname1=`date +%Y%m%d-%H%M-images-backup`
ddir=/drive2/backups/$dend
mkdir $ddir
#vzdump --dumpdir $ddir --snapshot --all
mkdir $ddir/kvm
lvcreate -s -L 2g -n backupsnapshot /dev/pve/data
mount /dev/mapper/pve-backupsnapshot /backupsnapshot
7z a -mx=9 $ddir/kvm/$dname1 /backupsnapshot/images/*
cp /etc/qemu-server/* $ddir/kvm/
umount /backupsnapshot
lvremove -f /dev/pve/backupsnapshot
exit 0

This dog don't hunt.
 
Nothing obviously wrong that I can see from a quick glance, it might help to run it manually and see which step fails on you.

Your lvcreate line for your snapshot might be too big, try 1g instead of 2g.

With the defaults in Proxmox PVE I wasn't able to do a very large LVM snapshot, I had to use 1g.
 
still no joy....

Nothing obviously wrong that I can see from a quick glance, it might help to run it manually and see which step fails on you.

Your lvcreate line for your snapshot might be too big, try 1g instead of 2g.

With the defaults in Proxmox PVE I wasn't able to do a very large LVM snapshot, I had to use 1g.

I just get a 35 byte empty file. Where in the script does it not to snapshot from /var/lib/vz/images/* ???...this is not anywhere in the revised script.

Also, I assume I have to create the directory /backupsnapshot (I believe script failed prior to my doing that).
 
You probably need to create /backupsnapshot/images also.

Do each step of this manually yourself and check the result after each command. If the results aren't as expected, you've found the step that is failing.
 
You probably need to create /backupsnapshot/images also.

Do each step of this manually yourself and check the result after each command. If the results aren't as expected, you've found the step that is failing.

But I don't understand which step copies from /var/lib/vz/images/* ...as this is nowhere in any of the steps.
 
You're right, you'll be needing a step to copy whichever qcow2 files you need from /var/lib/vz/images to $ddir/kvm/$dname1 or wherever appropriate for you.

Hopefully you can figure out how to write your own simple basic script to lvcreate, mount, copy and/or 7zip or gzip, umount and lvremove... I can't do it for you, sorry.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!