KVM Snapshot/Backup Script
-
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates this basically is a super fast clone of the original vm using snapshots?
It takes a snapshot, which directs writes to the new file. Then tars and gzips the backing store (original disk image) to wherever you put in for the location, and then merges the snapshot back into the backing store.
This is too keep the system live during the backup?
-
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates this basically is a super fast clone of the original vm using snapshots?
It takes a snapshot, which directs writes to the new file. Then tars and gzips the backing store (original disk image) to wherever you put in for the location, and then merges the snapshot back into the backing store.
This is too keep the system live during the backup?
Right. If you don't do it this way, you have to either shut the VM down or suspend it.
-
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
-
@Romo said in KVM Snapshot/Backup Script:
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
No. I have a template that uses a qcow2 disk. It's only a 15GB disk, but since it's thin provisioned it's only around 1.5GB. I can clone it in about 1-2 seconds so I haven't bothered with doing externals for that. However, it does make a nice VDI tool. If you have an image and do qemu-img create -b and use it as the backing file, the overlays spin up really quickly. Like less than a second. But you can't write to the backing file as long as there are overlay files reading from it.
-
I create the template, and run virt-sysprep on it. Then I can update the disk with virt-sysprep --update. It automatically spins up a temp VM that updates all of the packages in the disk. But if you do this, you need to run virt-sysprep --selinux-relabel so it relabels the disk on the next clone. If not, labels can get screwed up;
-
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
No. I have a template that uses a qcow2 disk. It's only a 15GB disk, but since it's thin provisioned it's only around 1.5GB. I can clone it in about 1-2 seconds so I haven't bothered with doing externals for that.
My clones take 30-40 seconds, how do you thin provision? Using virt-sparsify on an image?
-
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
No. I have a template that uses a qcow2 disk. It's only a 15GB disk, but since it's thin provisioned it's only around 1.5GB. I can clone it in about 1-2 seconds so I haven't bothered with doing externals for that.
My clones take 30-40 seconds, how do you thin provision? Using virt-sparsify on an image?
No, qcow2 is thin by default. But all of my templates are RHEL systems. So the OS doesn't use hardly any space. Are you cloning Windows machines?
-
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
No. I have a template that uses a qcow2 disk. It's only a 15GB disk, but since it's thin provisioned it's only around 1.5GB. I can clone it in about 1-2 seconds so I haven't bothered with doing externals for that.
My clones take 30-40 seconds, how do you thin provision? Using virt-sparsify on an image?
No, qcow2 is thin by default. But all of my templates are RHEL systems. So the OS doesn't use hardly any space. Are you cloning Windows machines?
No, no windows
-
@stacksofplates said in KVM Snapshot/Backup Script:
I create the template, and run virt-sysprep on it. Then I can update the disk with virt-sysprep --update. It automatically spins up a temp VM that updates all of the packages in the disk. But if you do this, you need to run virt-sysprep --selinux-relabel so it relabels the disk on the next clone. If not, labels can get screwed up;
Is this is only available for RHEL guests or can it be used with other distros?
-
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
No. I have a template that uses a qcow2 disk. It's only a 15GB disk, but since it's thin provisioned it's only around 1.5GB. I can clone it in about 1-2 seconds so I haven't bothered with doing externals for that.
My clones take 30-40 seconds, how do you thin provision? Using virt-sparsify on an image?
No, qcow2 is thin by default. But all of my templates are RHEL systems. So the OS doesn't use hardly any space. Are you cloning Windows machines?
No, no windows
Hmm, I don't have anything special. Some 300G 10K SAS drives in RAID 10.
Here's a video I did for Dash:
Youtube VideoAnd another of a script I wrote that names the VM and spins up how many instances you tell it:
Youtube Video -
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
I create the template, and run virt-sysprep on it. Then I can update the disk with virt-sysprep --update. It automatically spins up a temp VM that updates all of the packages in the disk. But if you do this, you need to run virt-sysprep --selinux-relabel so it relabels the disk on the next clone. If not, labels can get screwed up;
Is this is only available for RHEL guests or can it be used with other distros?
You should be able to sysprep Ubuntu also. Not sure about any others.
-
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
No. I have a template that uses a qcow2 disk. It's only a 15GB disk, but since it's thin provisioned it's only around 1.5GB. I can clone it in about 1-2 seconds so I haven't bothered with doing externals for that.
My clones take 30-40 seconds, how do you thin provision? Using virt-sparsify on an image?
No, qcow2 is thin by default. But all of my templates are RHEL systems. So the OS doesn't use hardly any space. Are you cloning Windows machines?
No, no windows
Hmm, I don't have anything special. Some 300G 10K SAS drives in RAID 10.
Here's a video I did for Dash:
Youtube VideoAnd another of a script I wrote that names the VM and spins up how many instances you tell it:
Youtube VideoI want that speed!! I am on 4 500GB 7200 SATA in RAID 10
-
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
No. I have a template that uses a qcow2 disk. It's only a 15GB disk, but since it's thin provisioned it's only around 1.5GB. I can clone it in about 1-2 seconds so I haven't bothered with doing externals for that.
My clones take 30-40 seconds, how do you thin provision? Using virt-sparsify on an image?
No, qcow2 is thin by default. But all of my templates are RHEL systems. So the OS doesn't use hardly any space. Are you cloning Windows machines?
No, no windows
Hmm, I don't have anything special. Some 300G 10K SAS drives in RAID 10.
Here's a video I did for Dash:
Youtube VideoAnd another of a script I wrote that names the VM and spins up how many instances you tell it:
Youtube VideoI want that speed!! I am on 4 500GB 7200 SATA in RAID 10
How big is your template?
2.0G -rw-------. 1 root root 16G Feb 13 03:37 template.qcow2
That's what I have.
-
Also it's not virt-sysprep --update it's virt-customize --update. I didn't think that was right, so I just went back and looked.
I have a daily cron job that runs this
/bin/virt-customize --update --selinux-relabel -a /data/VMs/template.qcow2
-
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
No. I have a template that uses a qcow2 disk. It's only a 15GB disk, but since it's thin provisioned it's only around 1.5GB. I can clone it in about 1-2 seconds so I haven't bothered with doing externals for that.
My clones take 30-40 seconds, how do you thin provision? Using virt-sparsify on an image?
No, qcow2 is thin by default. But all of my templates are RHEL systems. So the OS doesn't use hardly any space. Are you cloning Windows machines?
No, no windows
Hmm, I don't have anything special. Some 300G 10K SAS drives in RAID 10.
Here's a video I did for Dash:
Youtube VideoAnd another of a script I wrote that names the VM and spins up how many instances you tell it:
Youtube VideoI want that speed!! I am on 4 500GB 7200 SATA in RAID 10
How big is your template?
2.0G -rw-------. 1 root root 16G Feb 13 03:37 template.qcow2
That's what I have.
Way bigger, apparently its not thing provisioned at all
1 root root 2.9G Oct 26 17:39 centos7-clone.qcow2 1 root root 26G Feb 8 15:35 centos-7.qcow2
-
I use this to create my image and the use virt-manager to finish the install
qemu-img create -f qcow2 -o preallocation=metadata centos-7.qcow2 25G
-
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates said in KVM Snapshot/Backup Script:
@Romo said in KVM Snapshot/Backup Script:
Are you using external snapshots to thin provision any vms? Is there a performance hit on doing this?
No. I have a template that uses a qcow2 disk. It's only a 15GB disk, but since it's thin provisioned it's only around 1.5GB. I can clone it in about 1-2 seconds so I haven't bothered with doing externals for that.
My clones take 30-40 seconds, how do you thin provision? Using virt-sparsify on an image?
No, qcow2 is thin by default. But all of my templates are RHEL systems. So the OS doesn't use hardly any space. Are you cloning Windows machines?
No, no windows
Hmm, I don't have anything special. Some 300G 10K SAS drives in RAID 10.
Here's a video I did for Dash:
Youtube VideoAnd another of a script I wrote that names the VM and spins up how many instances you tell it:
Youtube VideoI want that speed!! I am on 4 500GB 7200 SATA in RAID 10
How big is your template?
2.0G -rw-------. 1 root root 16G Feb 13 03:37 template.qcow2
That's what I have.
Way bigger, apparently its not thing provisioned at all
1 root root 2.9G Oct 26 17:39 centos7-clone.qcow2 1 root root 26G Feb 8 15:35 centos-7.qcow2
was that with ls -lsh? It should give you the actual size on the left before the permissions.
I use a minimal image by default, then just add what I need after the clone.
-
@stacksofplates I only did a ls -lh
output of ls -lsh
2.9G -rw-r--r--. 1 root root 2.9G Oct 26 17:39 centos7-clone.qcow2 1.1G -rw-r--r--. 1 root root 26G Feb 8 15:35 centos-7.qcow2
-
@Romo said in KVM Snapshot/Backup Script:
I use this to create my image and the use virt-manager to finish the install
qemu-img create -f qcow2 -o preallocation=metadata centos-7.qcow2 25G
I preallocated the original template, and then when I clone with Virt-Manager or cli I don't usually change it after. I did some tests and didn't see any difference between running the preallocation on the clone and not. I'm not sure if it copies the preallocation flag when you clone, but like I said, I haven't seen much of a read/write difference.
-
@Romo said in KVM Snapshot/Backup Script:
@stacksofplates I only did a ls -lh
output of ls -lsh
2.9G -rw-r--r--. 1 root root 2.9G Oct 26 17:39 centos7-clone.qcow2 1.1G -rw-r--r--. 1 root root 26G Feb 8 15:35 centos-7.qcow2
Ya so it's thin provisioned. I wonder why it's taking so long. I don't think the disk speeds would make that much of a difference.