KVM Backups - DO NOT USE



  • I figured I'd do a quick write up of a simple way to do backups with KVM.

    First you have to add the qemu-guest-agent to the VMs you want to back up.

    yum install qemu-guest-agent
    

    or

    apt-get install qemu-guest-agent
    

    Make sure the agent is running and enabled (not 100% sure if you need to run the systemctl enable or not).

    systemctl start qemu-guest-agent
    systemctl enable qemu-guest-agent
    

    Then you need to add the agent channel in the VM. You can do this with either Virt-Manager or directly editing the VM xml file. Since I'm lazy, I'll just do it through Virt-Manager. Open the VM and click Add New Hardware, then select Channel and the org.qemu.guest_agent.0 and click Finish.

    0_1462150597929_new_hardware.png

    Now we can back up the VM. I just wrote a little script that does this (This method is assuming your .qcow2 images have the same names as the VMs). It's also backing up to an NFS server mounted at /backup and getting the images from /data/VMs.

    #!/bin/bash
    
    today=$(date +"%m-%d-%Y")
    
    for i in VM1 VM2 VM3 VM4
    do
      # Export XML
      virsh dumpxml $i > /backup/$i.xml
      # Freeze VM filesystems
      virsh domfsfreeze $i
      # Create VM snapshot
      qemu-img create -f qcow2 -b /data/VMs/$i.qcow2 /data/VMs/$i-snap-$today.qcow2
      # Thaw VM filesystems
      virsh domfsthaw $i
      # Take backup from VM snapshot
      qemu-img convert -O raw /data/VMs/$i-snap-$today.qcow2 /backup/$i-$today.img
      # Delete snapshot
      rm -f /data/VMs/$i-snap-$today.qcow2
    done
    

    Add it to a cron job and that's it. This method doesn't compress the images however. To do that you can just add a line to tar the image in the for loop.

    Edit: this method is incorrect. Please use this method instead: https://mangolassi.it/topic/12537/kvm-snapshot-backup-script



  • In light of the XS HVD size limitation of 2 TB is KVM a better choice? or moving to native Xen instead of XenServer?



  • @Dashrender said in KVM Backups:

    In light of the XS HVD size limitation of 2 TB is KVM a better choice? or moving to native Xen instead of XenServer?

    XS limitations over Xen should not prompt a consideration of KVM. It's only the XS interface itself that has the limitation.



  • So should we be looking to do a fall back to Xen? I'm guessing in doing so we'll also loose XO support as well?



  • @Dashrender said in KVM Backups:

    So should we be looking to do a fall back to Xen? I'm guessing in doing so we'll also loose XO support as well?

    By default, yes. I believe that you can apply the XAPI API (is that redundant?) to the Xen install and then attach with XO. Would be a good project to do.



  • @scottalanmiller said in KVM Backups:

    @Dashrender said in KVM Backups:

    So should we be looking to do a fall back to Xen? I'm guessing in doing so we'll also loose XO support as well?

    By default, yes. I believe that you can apply the XAPI API (is that redundant?) to the Xen install and then attach with XO. Would be a good project to do.

    Ha I always wondered if it was, but then you mention XAPI and not API and people have no idea what you're saying.



  • I think that XAPI is its actual name, so API is actually needed.



  • "Plain" Xen or KVM would need an agent installed on each host to expose an "enough advanced" API (probably something ugly like libvirt+custom scripts). Take a look a oVirt project for this.

    Anyway, XO is only working on XAPI (which is the project name of this Xen API). APIs can be confusing because there is various level of APIs: low level APIs (like lib-xl or a part of lib-virt), and more "turnkey"/complete API like XAPI, which handle a lot of stuff (not only the hypervisor, but also the glue around it).

    That's why XAPI project is more than just an API, but a "toolstack". See http://wiki.xen.org/wiki/Choice_of_Toolstacks

    For example, Amazon got its own toolstack (not public) on top of Xen.


  • Vendor

    Aren't there any agent-less KVM backups available? Anything like Veeam?



  • @KOOLER said in KVM Backups:

    Aren't there any agent-less KVM backups available? Anything like Veeam?

    None that I know of. Scale does an agentless backup but you have to have a Scale cluster, not just KVM.


  • Vendor

    @scottalanmiller said in KVM Backups:

    @KOOLER said in KVM Backups:

    Aren't there any agent-less KVM backups available? Anything like Veeam?

    None that I know of. Scale does an agentless backup but you have to have a Scale cluster, not just KVM.

    I was under impression they license somebody's else technology, don't they?



  • @KOOLER said in KVM Backups:

    @scottalanmiller said in KVM Backups:

    I was under impression they license somebody's else technology, don't they?

    For their basic backup, no it's all internal. For more advanced features they work with third parties but don't license it, it's sold separately.


  • Vendor

    @scottalanmiller said in KVM Backups:

    @KOOLER said in KVM Backups:

    @scottalanmiller said in KVM Backups:

    I was under impression they license somebody's else technology, don't they?

    For their basic backup, no it's all internal. For more advanced features they work with third parties but don't license it, it's sold separately.

    Do you use their agentless backup? How do you find it against say Unitrends or Veeam? thanks!



  • It's very basic. Just full images and automated exports. Nothing extensive. But for firms needing a basic, free backup mechanism, it gets them that. In most cases you would still want something more robust, like StorageCraft, Unitrends or the like. A Veeam product for it would be awesome. But it is enough to get automated data protection in place.


  • Vendor

    @scottalanmiller said in KVM Backups:

    It's very basic. Just full images and automated exports. Nothing extensive. But for firms needing a basic, free backup mechanism, it gets them that. In most cases you would still want something more robust, like StorageCraft, Unitrends or the like. A Veeam product for it would be awesome. But it is enough to get automated data protection in place.

    See Inbox 😉



  • Qemu has some kind of incremental backup, but I haven't investigated much.

    I just want to point out that one advantage to exporting to a raw .img file is that you can mount the image and pull files directly. If you need to import, just have qemu convert the .img back to a .qcow2 file and use the XML dump to rebuild the VM.



  • @scottalanmiller said in KVM Backups:

    It's very basic. Just full images and automated exports. Nothing extensive. But for firms needing a basic, free backup mechanism, it gets them that. In most cases you would still want something more robust, like StorageCraft, Unitrends or the like. A Veeam product for it would be awesome. But it is enough to get automated data protection in place.

    Is the move away from an agent based backup really worth that much?

    Didn't we have this conversation a few months ago?



  • @Dashrender said in KVM Backups:

    @scottalanmiller said in KVM Backups:

    It's very basic. Just full images and automated exports. Nothing extensive. But for firms needing a basic, free backup mechanism, it gets them that. In most cases you would still want something more robust, like StorageCraft, Unitrends or the like. A Veeam product for it would be awesome. But it is enough to get automated data protection in place.

    Is the move away from an agent based backup really worth that much?

    Didn't we have this conversation a few months ago?

    Unlike a lot of people, I'm fine with agent based. It might not be ideal, but it isn't bad. The big move here, though, is to "free and included."



  • I gotcha... So there is a free and included one in KVM, but no Xen or XS right?



  • @Dashrender said in KVM Backups:

    I gotcha... So there is a free and included one in KVM, but no Xen or XS right?

    There is a free, included one in Scale and one in XO.



  • Remember, KVM and Xen are base products. They "include nothing" because it would be foolish for anything to exist there. The idea that everything should be built in monolithically is a Windows one. That doesn't make it wrong, it is just one approach and idealistically opposed to all product markets except for Windows. One of the things that the Vmware crowd brags about is how little ESXi does (seriously, they do this.)

    Xen and KVM actually do... nothing. It's their support environments that do everything. For Scale, it's the Scale system, not KVM, that does all of the features. With Xen a lot of features come from XenServer and a lot more come from Xen Orchestra. But those things are part of the ecosystem that you get for free. So it kind of feels like they are included, but really they are layered on top, as they should be.

    Just like Xen doesn't include DRBD or Gluster or CEPH, but Xen's ecosystem always includes them.



  • You're right.. I have to keep reminding myself of that. But SMB's don't want to be chasing down dozens of little pieces all over the place to make these pieces work.

    It's one thing or a larger company to have a team who's job it is to do just that - Scott's been talking about using Xen for decade plus. I have to assume that Scott the one man who is equal to nearly 10 normal mortals, has managed to collect and put together all of those parts.

    The simplicity of XS and XO are what really give Xen any teeth in the SMB market, a la Windows style, everything in one place.

    The bad thing about these groupings though, as we found out with the use of VHDs in XS, are the limitations those packages place upon us.



  • @Dashrender said in KVM Backups:

    You're right.. I have to keep reminding myself of that. But SMB's don't want to be chasing down dozens of little pieces all over the place to make these pieces work.

    It's hardly chasing down lots of pieces. It's XenServer + Xen Orchestra on one side. Or just Scale on the other.

    Compare that to VMware. You need VMware, Starwind, Veeam and how many more components to add up to just one or two in the KVM or Xen worlds? And licensing is the equivalent to many pieces, at least in terms of tracking down and complexity.

    Hyper-V isn't quite as bad, but similar. You have Hyper-V confusion, tools for managing Hyper-V, Veeam, Starwind, etc.

    The open sources pieces, even though they are separate, are normally bundled more completely than the VMware and Microsoft equivalents.



  • @scottalanmiller said in KVM Backups:

    @Dashrender said in KVM Backups:

    You're right.. I have to keep reminding myself of that. But SMB's don't want to be chasing down dozens of little pieces all over the place to make these pieces work.

    It's hardly chasing down lots of pieces. It's XenServer + Xen Orchestra on one side. Or just Scale on the other.

    That's not what I meant.. I mean Xen.. then going and finding all of the other things you need to go along with Xen.



  • @Dashrender said in KVM Backups:

    The simplicity of XS and XO are what really give Xen any teeth in the SMB market, a la Windows style, everything in one place.

    Here is where I was giving props to XS and XO for bundling things together to make it easier.



  • @Dashrender said in KVM Backups:

    @scottalanmiller said in KVM Backups:

    @Dashrender said in KVM Backups:

    You're right.. I have to keep reminding myself of that. But SMB's don't want to be chasing down dozens of little pieces all over the place to make these pieces work.

    It's hardly chasing down lots of pieces. It's XenServer + Xen Orchestra on one side. Or just Scale on the other.

    That's not what I meant.. I mean Xen.. then going and finding all of the other things you need to go along with Xen.

    But you don't. Just like you don't get ESXi without vSphere. You don't get Xen alone. That's silly.

    That's like saying that you went and got the NT kernel and boy is it complicated to build your own windows OS around it. No, you get Windows which is the NT kernel and all the other stuff packaged together.



  • @Dashrender said in KVM Backups:

    @Dashrender said in KVM Backups:

    The simplicity of XS and XO are what really give Xen any teeth in the SMB market, a la Windows style, everything in one place.

    Here is where I was giving props to XS and XO for bundling things together to make it easier.

    I see.



  • @scottalanmiller said in KVM Backups:

    @Dashrender said in KVM Backups:

    @scottalanmiller said in KVM Backups:

    @Dashrender said in KVM Backups:

    You're right.. I have to keep reminding myself of that. But SMB's don't want to be chasing down dozens of little pieces all over the place to make these pieces work.

    It's hardly chasing down lots of pieces. It's XenServer + Xen Orchestra on one side. Or just Scale on the other.

    That's not what I meant.. I mean Xen.. then going and finding all of the other things you need to go along with Xen.

    But you don't. Just like you don't get ESXi without vSphere. You don't get Xen alone. That's silly.

    That's like saying that you went and got the NT kernel and boy is it complicated to build your own windows OS around it. No, you get Windows which is the NT kernel and all the other stuff packaged together.

    But if you want a Xen solution today that supports VMs with image files larger than 2 TB, you can't use XS, and therefore can't use XO either.. so what is your option then?

    Sure you can bandaid it with spanning, but come on, should that really be required?



  • @Dashrender said

    But if you want a Xen solution today that supports VMs with image files larger than 2 TB, you can't use XS, and therefore can't use XO either.. so what is your option then?

    Have less data.

    (JOKE.)



  • When XO grows up to be more fully functional, then I will consider replacing Hyper-V with XS.

    The potential in XO is awesome, but it is too much work for not enough of a return still.

    Hyper-V + Veeam is solid, well known, and handles everything needed.

    Ignore the "confusion" comment @scottalanmiller made because it exists with all hypervisors in the SMB.

    Also, Starwind (good product, but) is a waste in the SMB. Very few need more than a single server. The few that do, can then just get by with Hyper-V replication for their pseudo fail over needs.