Skip to contentSkip to conversation

How to create a backup of an LVM based maschine without wasting space

User Question Lukas Laukamp 4 participants 26 messages Oct 12, 2012 – Oct 18, 2012 1 message not in the archive KVM

lore
Share & tools
lore
#0 lore raw

Hey all,

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

Is this supported by qemu_backup or what would be the best way to do this?

PS: Sorry for my bed english

Best Regards

#1 lore raw
Quoted 7 lines · Lukas Laukamp

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001 vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions.

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan

#3 lore raw
In reply to a message not in the archive

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 32 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 17 lines · Lukas Laukamp
Quoted 7 lines

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001 vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would be a offline backup. For the online backup I think about a seperated system which every day makes incremental backups and once a week a full backup. The main problem is, that the systems are in a WAN network and I need encryption between the systems. Would it be possible to do something like this: create the LVM snapshot for the backup, read this LVM snapshot with the remote backup system via ssh tunnel and save the output of this to qcow2 files on the backup system? And in which format could be the incremental backups be stored?

Best Regards

#4 lore raw
Quoted 44 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 42 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 20 lines · Lukas Laukamp
Quoted 8 lines

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001 vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would be a offline backup. For the online backup I think about a seperated system which every day makes incremental backups and once a week a full backup. The main problem is, that the systems are in a WAN network and I need encryption between the systems. Would it be possible to do something like this: create the LVM snapshot for the backup, read this LVM snapshot with the remote backup system via ssh tunnel and save the output of this to qcow2 files on the backup system? And in which format could be the incremental backups be stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Stefan

#5 lore raw

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 54 lines · Lukas Laukamp
Quoted 40 lines

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 38 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 17 lines · Lukas Laukamp
Quoted 7 lines

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001 vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would be a offline backup. For the online backup I think about a seperated system which every day makes incremental backups and once a week a full backup. The main problem is, that the systems are in a WAN network and I need encryption between the systems. Would it be possible to do something like this: create the LVM snapshot for the backup, read this LVM snapshot with the remote backup system via ssh tunnel and save the output of this to qcow2 files on the backup system? And in which format could be the incremental backups be stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefan,

the rsync part I don't have understood fully. So to create a qcow2 on the host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and simply transfer the differences to the file? Or does it work on another way?

Best Regards

#6 lore raw
Quoted 76 lines · Lukas Laukamp

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 67 lines · Lukas Laukamp
Quoted 52 lines

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 49 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 20 lines · Lukas Laukamp
Quoted 8 lines

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001 vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would
be a offline backup. For the online backup I think about a seperated system
which every day makes incremental backups and once a week a full backup. The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote backup system via ssh tunnel and save the output of this to qcow2 files on
the backup system? And in which format could be the incremental backups be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 7 lines

Hello Stefan,

the rsync part I don't have understood fully. So to create a qcow2 on the host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and simply transfer the differences to the file? Or does it work on another way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Stefan

#7 lore raw

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 88 lines · Lukas Laukamp
Quoted 69 lines

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 61 lines · Lukas Laukamp
Quoted 47 lines

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 45 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 17 lines · Lukas Laukamp
Quoted 7 lines

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001 vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would
be a offline backup. For the online backup I think about a seperated system
which every day makes incremental backups and once a week a full backup. The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote backup system via ssh tunnel and save the output of this to qcow2 files on
the backup system? And in which format could be the incremental backups be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 7 lines

Hello Stefan,

the rsync part I don't have understood fully. So to create a qcow2 on the host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and simply transfer the differences to the file? Or does it work on another way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

So I simply update the full backup, which is simply a raw file which get mounted while the backup?

Best Regards

#8 lore raw
Quoted 114 lines · Lukas Laukamp

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 105 lines · Lukas Laukamp
Quoted 84 lines

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 74 lines
Quoted 58 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 55 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 22 lines · Lukas Laukamp
Quoted 8 lines

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you
can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would
be a offline backup. For the online backup I think about a seperated system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 8 lines

Hello Stefan,

the rsync part I don't have understood fully. So to create a qcow2 on the host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and simply transfer the differences to the file? Or does it work on another way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 2 lines

So I simply update the full backup, which is simply a raw file which get mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Stefan

#9 lore raw

Am 12.10.2012 13:36, schrieb Stefan Hajnoczi:

Quoted 105 lines · Lukas Laukamp
Quoted 104 lines

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 101 lines · Lukas Laukamp
Quoted 76 lines

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 68 lines
Quoted 53 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 51 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 19 lines · Lukas Laukamp
Quoted 7 lines

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you
can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would
be a offline backup. For the online backup I think about a seperated system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 8 lines

Hello Stefan,

the rsync part I don't have understood fully. So to create a qcow2 on the host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and simply transfer the differences to the file? Or does it work on another way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 5 lines
Quoted 2 lines

So I simply update the full backup, which is simply a raw file which get mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Stefan

Ah, thats great so to have a complete task in mind:

1. Create a qcow2 of a snapshot of an running VM
2. Transfer the qcow2 to the backup node
3. For incremental backup sync a daily LVM snapshot with the image on the backup node via rsync

Is that right?

Best Regards

#10 lore raw
Quoted 136 lines · Lukas Laukamp

Am 12.10.2012 13:36, schrieb Stefan Hajnoczi:

Quoted 125 lines · Lukas Laukamp
Quoted 124 lines

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 119 lines
Quoted 92 lines · Lukas Laukamp

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 80 lines
Quoted 64 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 61 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 28 lines · Lukas Laukamp
Quoted 13 lines

I have a simple user question. I have a few LVM based KVM guests and
wan't to backup them to files. The simple and nasty way would be to
create a complete output file with dd, which wastes very much space.
So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the
output file would be something like a qcow2 file which could be also
simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you
can use cp(1) to copy the LVM volume to a raw file. It will not use
disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would
be a offline backup. For the online backup I think about a seperated system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefan,

Quoted 8 lines

the rsync part I don't have understood fully. So to create a qcow2 on the
host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and
simply transfer the differences to the file? Or does it work on another way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 7 lines
Quoted 2 lines

So I simply update the full backup, which is simply a raw file which get mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Stefan

Quoted 6 lines

Ah, thats great so to have a complete task in mind:

1. Create a qcow2 of a snapshot of an running VM
2. Transfer the qcow2 to the backup node
3. For incremental backup sync a daily LVM snapshot with the image on the backup node via rsync

Yes. Only make sure not to rsync the raw LVM image onto the qcow2 image - the backup client needs to have a raw image if you're syncing directly against the raw LVM volume.

Stefan

#11 lore raw

Am 12.10.2012 14:59, schrieb Stefan Hajnoczi:

Quoted 130 lines · Lukas Laukamp
Quoted 121 lines

Am 12.10.2012 13:36, schrieb Stefan Hajnoczi:

Quoted 119 lines · Lukas Laukamp
Quoted 107 lines

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 105 lines
Quoted 84 lines · Lukas Laukamp

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 74 lines
Quoted 59 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 57 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 25 lines · Lukas Laukamp
Quoted 4 lines

I have a simple user question. I have a few LVM based KVM guests and
wan't to backup them to files. The simple and nasty way would be to

Quoted 8 lines

create a complete output file with dd, which wastes very much space.
So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the
output file would be something like a qcow2 file which could be also
simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you
can use cp(1) to copy the LVM volume to a raw file. It will not use
disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would
be a offline backup. For the online backup I think about a seperated system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefan,

Quoted 8 lines

the rsync part I don't have understood fully. So to create a qcow2 on the
host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and
simply transfer the differences to the file? Or does it work on another way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Quoted 8 lines
Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

So I simply update the full backup, which is simply a raw file which get mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Quoted 8 lines
Quoted 1 line

Stefan

Ah, thats great so to have a complete task in mind:

1. Create a qcow2 of a snapshot of an running VM
2. Transfer the qcow2 to the backup node
3. For incremental backup sync a daily LVM snapshot with the image on the backup node via rsync

Quoted 5 lines

Yes. Only make sure not to rsync the raw LVM image onto the qcow2 image - the backup client needs to have a raw image if you're syncing directly against the raw LVM volume.

Stefan

So I should use a raw file for the syncing and convert it on the backup node to a qcow2 to have a good file format?

Best Regards

#12 lore raw
Quoted 165 lines · Lukas Laukamp

Am 12.10.2012 14:59, schrieb Stefan Hajnoczi:

Quoted 163 lines · Lukas Laukamp
Quoted 151 lines

Am 12.10.2012 13:36, schrieb Stefan Hajnoczi:

Quoted 138 lines
Quoted 136 lines · Lukas Laukamp

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 131 lines
Quoted 101 lines · Lukas Laukamp

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 89 lines
Quoted 70 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 67 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 31 lines · Lukas Laukamp
Quoted 14 lines

I have a simple user question. I have a few LVM based KVM guests and
wan't to backup them to files. The simple and nasty way would be to
create a complete output file with dd, which wastes very much space.
So I would like to create a backup of the LVM to a file which only
locates the space which is used on the LVM. Would be create when the
output file would be something like a qcow2 file which could be also
simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the
--sparse option in the man page). So you don't need to use qcow2,
you
can use cp(1) to copy the LVM volume to a raw file. It will not use
disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it
would
be a offline backup. For the online backup I think about a seperated
system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The
qcow2 file does not contain zero regions and will therefore save a lot
of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer
changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefan,

Quoted 11 lines

the rsync part I don't have understood fully. So to create a qcow2 on the
host, transfer this to the backup server will result in the weekly full
backup. So do you mean I could use rsync to read the LVM from the host,
compare the LVM data with the data in the qcow2 on the backup server and
simply transfer the differences to the file? Or does it work on another
way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 8 lines
Quoted 3 lines

So I simply update the full backup, which is simply a raw file which get
mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Stefan

Quoted 6 lines

Ah, thats great so to have a complete task in mind:

1. Create a qcow2 of a snapshot of an running VM
2. Transfer the qcow2 to the backup node
3. For incremental backup sync a daily LVM snapshot with the image on the backup node via rsync

Yes. Only make sure not to rsync the raw LVM image onto the qcow2 image - the backup client needs to have a raw image if you're syncing directly against the raw LVM volume.

Quoted 5 lines
Quoted 1 line

Stefan

So I should use a raw file for the syncing and convert it on the backup node to a qcow2 to have a good file format?

I would leave them raw as long as they are sparse (zero regions do not take up space). If you need to copy them you can either convert to qcow2 or use tools that preserve sparseness (BTW compression tools are good at this).

But it's up to you.

Stefan

#13 lore raw
Quoted 4 lines · Stefan Hajnoczi

I would leave them raw as long as they are sparse (zero regions do not take up space). If you need to copy them you can either convert to qcow2 or use tools that preserve sparseness (BTW compression tools are good at this).

note that free blocks previously used by deleted files won't be sparse, won't be zero and won't be much reduced by compression.

i'd say the usual advice stays:

A: if you run any non-trivial application on that VM, then use a real network backup tool 'from the inside' of the VM
B: if real point-in-time application-cache-storage consistency is not important, then you can:

- make a read-write LVM snapshot
- mount that and fsck. (it will appear as not-cleanly unmounted)
- backup the files. (i like rsync, especially if you have an uncompressed previous backup)
- umount and destroy the snapshot
- optionally compress the backup

but seriously consider option A before. especially important if you run any DB on that VM

Signature · 1 line
Javier
#14 lore raw

Am 12.10.2012 16:36, schrieb Javier Guerra Giraldez:

Quoted 23 lines · Stefan Hajnoczi
Quoted 4 lines

I would leave them raw as long as they are sparse (zero regions do not take up space). If you need to copy them you can either convert to qcow2 or use tools that preserve sparseness (BTW compression tools are good at this).

note that free blocks previously used by deleted files won't be sparse, won't be zero and won't be much reduced by compression.

i'd say the usual advice stays:

A: if you run any non-trivial application on that VM, then use a real network backup tool 'from the inside' of the VM
B: if real point-in-time application-cache-storage consistency is not important, then you can:

- make a read-write LVM snapshot
- mount that and fsck. (it will appear as not-cleanly unmounted)
- backup the files. (i like rsync, especially if you have an uncompressed previous backup)
- umount and destroy the snapshot
- optionally compress the backup

Quoted 3 lines

but seriously consider option A before. especially important if you run any DB on that VM

I already thought about such situations. So DB systems are a real problem. I know that some data can be better backup directly but for example a VM for a Web- or Mailserver I want to backup completely to get this services get to work again very fast if there are problems. So it's a complex problem I think and not every machine can be backuped as another.

I think that I must start by the hardware and software configuration of the backup node.

Best Regards

#16 lore raw
In reply to Stefan Hajnoczi

Am 12.10.2012 13:36, schrieb Stefan Hajnoczi:

Quoted 105 lines · Lukas Laukamp
Quoted 104 lines

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 101 lines · Lukas Laukamp
Quoted 76 lines

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 68 lines
Quoted 53 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 51 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 19 lines · Lukas Laukamp
Quoted 7 lines

I have a simple user question. I have a few LVM based KVM guests and wan't to backup them to files. The simple and nasty way would be to create a complete output file with dd, which wastes very much space. So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the output file would be something like a qcow2 file which could be also simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you
can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would
be a offline backup. For the online backup I think about a seperated system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 8 lines

Hello Stefan,

the rsync part I don't have understood fully. So to create a qcow2 on the host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and simply transfer the differences to the file? Or does it work on another way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 5 lines
Quoted 2 lines

So I simply update the full backup, which is simply a raw file which get mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Stefan

I tested the qemu-img command now, but it does not do that what I want. I have a VM with a 5GB disk, this disk is not allocated with 1GB of data. When I do the convert command the output is a 5GB qcow2 disk. What do I have to do to get a qcow2 file with only the allocated space/data from the LVM? I also tried the -c option of qemu-img convert but the result was nearly the same.

Best Regards

#17 lore raw
Quoted 136 lines · Lukas Laukamp

Am 12.10.2012 13:36, schrieb Stefan Hajnoczi:

Quoted 125 lines · Lukas Laukamp
Quoted 124 lines

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 119 lines
Quoted 92 lines · Lukas Laukamp

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 80 lines
Quoted 64 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 61 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 28 lines · Lukas Laukamp
Quoted 13 lines

I have a simple user question. I have a few LVM based KVM guests and
wan't to backup them to files. The simple and nasty way would be to
create a complete output file with dd, which wastes very much space.
So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the
output file would be something like a qcow2 file which could be also
simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you
can use cp(1) to copy the LVM volume to a raw file. It will not use
disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would
be a offline backup. For the online backup I think about a seperated system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefan,

Quoted 8 lines

the rsync part I don't have understood fully. So to create a qcow2 on the
host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and
simply transfer the differences to the file? Or does it work on another way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 7 lines
Quoted 2 lines

So I simply update the full backup, which is simply a raw file which get mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Stefan

Quoted 6 lines

I tested the qemu-img command now, but it does not do that what I want. I have a VM with a 5GB disk, this disk is not allocated with 1GB of data. When I do the convert command the output is a 5GB qcow2 disk. What do I have to do to get a qcow2 file with only the allocated space/data from the LVM? I also tried the -c option of qemu-img convert but the result was nearly the same.

Please show the exact command-lines you are using and the qemu-img info <filename> output afterwards.

Stefan

#15 lore raw
In reply to Javier Guerra Giraldez
Quoted 24 lines · Javier Guerra Giraldez
Quoted 4 lines · Stefan Hajnoczi

I would leave them raw as long as they are sparse (zero regions do not take up space). If you need to copy them you can either convert to qcow2 or use tools that preserve sparseness (BTW compression tools are good at this).

note that free blocks previously used by deleted files won't be sparse, won't be zero and won't be much reduced by compression.

i'd say the usual advice stays:

A: if you run any non-trivial application on that VM, then use a real network backup tool 'from the inside' of the VM
B: if real point-in-time application-cache-storage consistency is not important, then you can:

- make a read-write LVM snapshot
- mount that and fsck. (it will appear as not-cleanly unmounted)
- backup the files. (i like rsync, especially if you have an uncompressed previous backup)
- umount and destroy the snapshot
- optionally compress the backup

Quoted 2 lines

but seriously consider option A before. especially important if you run any DB on that VM

Valid points. People seem to like crash-consistent image file backup though because it's convenient. It may not be backing up all application state though :(.

Regarding option B, your idea is better than what I've been suggesting. By mounting the image on the host and rsyncing the mounted files you avoid syncing dirty blocks in the image file (e.g. deleted data in the guest file system).

Stefan

#18 lore raw
In reply to Stefan Hajnoczi

Am 12.10.2012 21:13, schrieb Stefan Hajnoczi:

Quoted 130 lines · Lukas Laukamp
Quoted 121 lines

Am 12.10.2012 13:36, schrieb Stefan Hajnoczi:

Quoted 119 lines · Lukas Laukamp
Quoted 107 lines

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 105 lines
Quoted 84 lines · Lukas Laukamp

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 74 lines
Quoted 59 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 57 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 25 lines · Lukas Laukamp
Quoted 4 lines

I have a simple user question. I have a few LVM based KVM guests and
wan't to backup them to files. The simple and nasty way would be to

Quoted 8 lines

create a complete output file with dd, which wastes very much space.
So I would like to create a backup of the LVM to a file which only locates the space which is used on the LVM. Would be create when the
output file would be something like a qcow2 file which could be also
simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you
can use cp(1) to copy the LVM volume to a raw file. It will not use
disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it would
be a offline backup. For the online backup I think about a seperated system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The qcow2 file does not contain zero regions and will therefore save a lot of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefan,

Quoted 8 lines

the rsync part I don't have understood fully. So to create a qcow2 on the
host, transfer this to the backup server will result in the weekly full backup. So do you mean I could use rsync to read the LVM from the host, compare the LVM data with the data in the qcow2 on the backup server and
simply transfer the differences to the file? Or does it work on another way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Quoted 8 lines
Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

So I simply update the full backup, which is simply a raw file which get mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Quoted 8 lines
Quoted 1 line

Stefan

I tested the qemu-img command now, but it does not do that what I want. I have a VM with a 5GB disk, this disk is not allocated with 1GB of data. When I do the convert command the output is a 5GB qcow2 disk. What do I have to do to get a qcow2 file with only the allocated space/data from the LVM? I also tried the -c option of qemu-img convert but the result was nearly the same.

Quoted 8 lines

Please show the exact command-lines you are using and the qemu-img info <filename> output afterwards.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello,

the VM is called mailer and I used this command: qemu-img convert -f raw -c -O qcow2 /dev/vmdisks/mailer ./vmachines/mailer.qcow2

Im on the /mnt dir because it's a seperate HDD with the folder vmachines.

Thats the output of qemu-img info:

image: ./vmachines/mailer.qcow2
file format: qcow2
virtual size: 5.0G (5368709120 bytes)
disk size: 4.1G
cluster_size: 65536

I checked the info of the fs inside the guest. The / partition is 4,7GB big and 1,2GB are used. The fs is ext3.

Best Regards

#19 lore raw
Quoted 183 lines · Lukas Laukamp

Am 12.10.2012 21:13, schrieb Stefan Hajnoczi:

Quoted 162 lines · Lukas Laukamp
Quoted 151 lines

Am 12.10.2012 13:36, schrieb Stefan Hajnoczi:

Quoted 138 lines
Quoted 136 lines · Lukas Laukamp

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 131 lines
Quoted 101 lines · Lukas Laukamp

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 89 lines
Quoted 70 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 67 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 31 lines · Lukas Laukamp
Quoted 14 lines

I have a simple user question. I have a few LVM based KVM guests and
wan't to backup them to files. The simple and nasty way would be to
create a complete output file with dd, which wastes very much space.
So I would like to create a backup of the LVM to a file which only
locates the space which is used on the LVM. Would be create when the
output file would be something like a qcow2 file which could be also
simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the
--sparse option in the man page). So you don't need to use qcow2,
you
can use cp(1) to copy the LVM volume to a raw file. It will not use
disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it
would
be a offline backup. For the online backup I think about a seperated
system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The
qcow2 file does not contain zero regions and will therefore save a lot
of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer
changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefan,

Quoted 11 lines

the rsync part I don't have understood fully. So to create a qcow2 on the
host, transfer this to the backup server will result in the weekly full
backup. So do you mean I could use rsync to read the LVM from the host,
compare the LVM data with the data in the qcow2 on the backup server and
simply transfer the differences to the file? Or does it work on another
way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 8 lines
Quoted 3 lines

So I simply update the full backup, which is simply a raw file which get
mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Stefan

Quoted 9 lines

I tested the qemu-img command now, but it does not do that what I want. I have a VM with a 5GB disk, this disk is not allocated with 1GB of data. When
I do the convert command the output is a 5GB qcow2 disk. What do I have to
do to get a qcow2 file with only the allocated space/data from the LVM? I also tried the -c option of qemu-img convert but the result was nearly the
same.

Quoted 8 lines

Please show the exact command-lines you are using and the qemu-img info <filename> output afterwards.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello,

the VM is called mailer and I used this command: qemu-img convert -f raw -c -O qcow2 /dev/vmdisks/mailer ./vmachines/mailer.qcow2

Im on the /mnt dir because it's a seperate HDD with the folder vmachines.

Thats the output of qemu-img info:

Quoted 8 lines

image: ./vmachines/mailer.qcow2
file format: qcow2
virtual size: 5.0G (5368709120 bytes)
disk size: 4.1G
cluster_size: 65536

I checked the info of the fs inside the guest. The / partition is 4,7GB big and 1,2GB are used. The fs is ext3.

I wonder if you see better results without the -c option.

Stefan

#20 lore raw

Am 12.10.2012 22:43, schrieb Stefan Hajnoczi:

Quoted 176 lines · Lukas Laukamp
Quoted 167 lines

Am 12.10.2012 21:13, schrieb Stefan Hajnoczi:

Quoted 147 lines · Lukas Laukamp
Quoted 137 lines

Am 12.10.2012 13:36, schrieb Stefan Hajnoczi:

Quoted 127 lines
Quoted 125 lines · Lukas Laukamp

Am 12.10.2012 12:47, schrieb Stefan Hajnoczi:

Quoted 122 lines
Quoted 93 lines · Lukas Laukamp

Am 12.10.2012 12:11, schrieb Stefan Hajnoczi:

Quoted 83 lines
Quoted 65 lines · Lukas Laukamp

Am 12.10.2012 10:58, schrieb Lukas Laukamp:

Quoted 63 lines

Am 12.10.2012 10:42, schrieb Stefan Hajnoczi:

Quoted 28 lines · Lukas Laukamp
Quoted 13 lines

I have a simple user question. I have a few LVM based KVM guests
and
wan't to backup them to files. The simple and nasty way would be
to
create a complete output file with dd, which wastes very much
space.
So I would like to create a backup of the LVM to a file which
only
locates the space which is used on the LVM. Would be create when
the
output file would be something like a qcow2 file which could be
also
simply startet with KVM.

If the VM is not running you can use "qemu-img convert":

qemu-img convert -f raw -O qcow2 /dev/vg/vm001
vm001-backup.qcow2

Note that cp(1) tries to make the destination file sparse (see the
--sparse option in the man page). So you don't need to use qcow2,
you
can use cp(1) to copy the LVM volume to a raw file. It will not use
disk space for zero regions.

Quoted 8 lines

If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefano,

thanks for the fast reply. I will test this later. In my case now it
would
be a offline backup. For the online backup I think about a seperated
system
which every day makes incremental backups and once a week a full backup.
The
main problem is, that the systems are in a WAN network and I need encryption
between the systems. Would it be possible to do something like this:
create
the LVM snapshot for the backup, read this LVM snapshot with the remote
backup system via ssh tunnel and save the output of this to qcow2 files
on
the backup system? And in which format could be the incremental backups
be
stored?

Since there is a WAN link it's important to use a compact image representation before hitting the network. I would use qemu-img convert -O qcow2 on the host and only transfer the qcow2 output. The
qcow2 file does not contain zero regions and will therefore save a lot
of network bandwidth compared to accessing the LVM volume over the WAN.

If you are using rsync or another tool it's a different story. You could rsync the current LVM volume on the host over the last full backup, it should avoid transferring image data which is already present in the last full backup - the result is that you only transfer
changed data plus the rsync metadata.

Quoted 5 lines

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello Stefan,

Quoted 11 lines

the rsync part I don't have understood fully. So to create a qcow2 on the
host, transfer this to the backup server will result in the weekly full
backup. So do you mean I could use rsync to read the LVM from the host,
compare the LVM data with the data in the qcow2 on the backup server and
simply transfer the differences to the file? Or does it work on another
way?

When using rsync you can skip qcow2. Only two objects are needed:
1. The LVM volume on the host.
2. The last full backup on the backup client.

rsync compares #1 and #2 efficiently over the network and only transfers data from #1 which has changed.

After rsync completes your full backup image is identical to the LVM volume. Next week you can use it as the "last" image to rsync against.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 7 lines
Quoted 3 lines

So I simply update the full backup, which is simply a raw file which get
mounted while the backup?

The image file does not need to be mounted. Just rsync the raw image file.

Stefan

Quoted 9 lines

I tested the qemu-img command now, but it does not do that what I want. I have a VM with a 5GB disk, this disk is not allocated with 1GB of data. When
I do the convert command the output is a 5GB qcow2 disk. What do I have to
do to get a qcow2 file with only the allocated space/data from the LVM? I also tried the -c option of qemu-img convert but the result was nearly the
same.

Quoted 8 lines

Please show the exact command-lines you are using and the qemu-img info <filename> output afterwards.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hello,

the VM is called mailer and I used this command: qemu-img convert -f raw -c -O qcow2 /dev/vmdisks/mailer ./vmachines/mailer.qcow2

Im on the /mnt dir because it's a seperate HDD with the folder vmachines.

Thats the output of qemu-img info:

Quoted 8 lines

image: ./vmachines/mailer.qcow2
file format: qcow2
virtual size: 5.0G (5368709120 bytes)
disk size: 4.1G
cluster_size: 65536

I checked the info of the fs inside the guest. The / partition is 4,7GB big and 1,2GB are used. The fs is ext3.

Quoted 7 lines

I wonder if you see better results without the -c option.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

So I would say that the results are very similar. So with -c option the file is 650-800MB smaller but thats not very much. I have a few bigger VM disks with sizes like 100GB when we calculat that in % so we see that the compression is very ecactly 20% so I would have an 80GB image of a disk where only 3GBs are used inside the VM.

I think that it must be possible to create an image with a size like the used space + a few hundret MB with metadata or something like that.

Best Regards

#21 lore raw
Quoted 2 lines · Lukas Laukamp

I think that it must be possible to create an image with a size like the used space + a few hundret MB with metadata or something like that.

the 'best' way to do it is 'from within' the VM

the typical workaround is to mount/fsck a LVM snapshot (don't skip the fsck, or at least a journal replay)

beyond that, there are a few utilities for specific filesystems:
PartImage [1], dump/restore [2], and i'm sure some others. I don't know how would these behave with unclean images, which is what you get if you pull the image under the VM's feet.

[1] http://www.partimage.org/Main_Page
[2] http://dump.sourceforge.net/

Signature · 1 line
Javier
#22 lore raw

Am 12.10.2012 23:53, schrieb Javier Guerra Giraldez:

Quoted 8 lines · Lukas Laukamp
Quoted 2 lines

I think that it must be possible to create an image with a size like the used space + a few hundret MB with metadata or something like that.

the 'best' way to do it is 'from within' the VM

the typical workaround is to mount/fsck a LVM snapshot (don't skip the fsck, or at least a journal replay)

Quoted 10 lines

beyond that, there are a few utilities for specific filesystems:
PartImage [1], dump/restore [2], and i'm sure some others. I don't know how would these behave with unclean images, which is what you get if you pull the image under the VM's feet.

[1] http://www.partimage.org/Main_Page
[2] http://dump.sourceforge.net/

So when I boot the VM with for example a live debian system, what would be the best method to backup the complete disk /dev/vda with only the data which is on it over a secure network connection to a destination in the network.

Best Regards

#23 lore raw

Am 13.10.2012 12:28, schrieb Lukas Laukamp:

Quoted 15 lines

Am 12.10.2012 23:53, schrieb Javier Guerra Giraldez:

Quoted 14 lines · Lukas Laukamp
Quoted 2 lines

I think that it must be possible to create an image with a size like the used space + a few hundret MB with metadata or something like that.

the 'best' way to do it is 'from within' the VM

the typical workaround is to mount/fsck a LVM snapshot (don't skip the fsck, or at least a journal replay)

beyond that, there are a few utilities for specific filesystems:
PartImage [1], dump/restore [2], and i'm sure some others. I don't know how would these behave with unclean images, which is what you get if you pull the image under the VM's feet.

Quoted 12 lines
Quoted 4 lines

[1] http://www.partimage.org/Main_Page
[2] http://dump.sourceforge.net/

So when I boot the VM with for example a live debian system, what would be the best method to backup the complete disk /dev/vda with only the data which is on it over a secure network connection to a destination in the network.

Best Regards

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

I have backed up the data within the machine with partimage and fsarchiver. But it would be greate to have a better way than doing this over a live system.

Best Regards

#24 lore raw
Quoted 3 lines · Lukas Laukamp

I have backed up the data within the machine with partimage and fsarchiver. But it would be greate to have a better way than doing this over a live system.

make no mistake, the absolutely best way is from within the VM. It's the most consistent, safe and efficient method.

Doing it "from the outside" is attractive, but it's a hack, and in some cases you have to jump through several hoops to make it safe.

Signature · 1 line
Javier
#25 lore raw

Am 15.10.2012 05:06, schrieb Javier Guerra Giraldez:

Quoted 11 lines · Lukas Laukamp
Quoted 3 lines

I have backed up the data within the machine with partimage and fsarchiver. But it would be greate to have a better way than doing this over a live system.

make no mistake, the absolutely best way is from within the VM. It's the most consistent, safe and efficient method.

Doing it "from the outside" is attractive, but it's a hack, and in some cases you have to jump through several hoops to make it safe.

Because of the fact that this is a "problem" I bootet the VM with a live cd and made a backup of the important filesystems with the live system which runs inside the VM.

Best Regards

#26 lore raw
In reply to Stefan Hajnoczi
Quoted 14 lines · Stefan Hajnoczi
Quoted 14 lines

the VM is called mailer and I used this command: qemu-img convert -f raw -c -O qcow2 /dev/vmdisks/mailer ./vmachines/mailer.qcow2

Im on the /mnt dir because it's a seperate HDD with the folder vmachines.

Thats the output of qemu-img info:

image: ./vmachines/mailer.qcow2
file format: qcow2
virtual size: 5.0G (5368709120 bytes)
disk size: 4.1G
cluster_size: 65536

Quoted 4 lines
Quoted 2 lines

I checked the info of the fs inside the guest. The / partition is 4,7GB big and 1,2GB are used. The fs is ext3.

I wonder if you see better results without the -c option.

Since the image is on a logical volume, it may not have been cleared prior to use by the guest; or the guest is busy enough that it has overwritten all the blocks in the image.

You can try a manual trim by creating a large file in the guest consisting of all zeros, then deleting it:

dd < /dev/zero < /zeroes
rm zeroes

Afterwards you'll get a much smaller qcow image. Of course this requires working within the guest, and there is the risk of disrupting the guest by reaching the ENOSPC condition.

Signature · 1 line
error compiling committee.c: too many arguments to function