ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    KVM Backups - DO NOT USE

    IT Discussion
    linux kvm hypervisor how-to backups
    7
    35
    10.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stacksofplatesS
      stacksofplates
      last edited by stacksofplates

      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

      1 Reply Last reply Reply Quote 2
      • DashrenderD
        Dashrender
        last edited by

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

        scottalanmillerS 1 Reply Last reply Reply Quote 1
        • scottalanmillerS
          scottalanmiller @Dashrender
          last edited by

          @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.

          1 Reply Last reply Reply Quote 1
          • DashrenderD
            Dashrender
            last edited by

            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?

            scottalanmillerS 1 Reply Last reply Reply Quote 0
            • scottalanmillerS
              scottalanmiller @Dashrender
              last edited by

              @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.

              stacksofplatesS 1 Reply Last reply Reply Quote 0
              • stacksofplatesS
                stacksofplates @scottalanmiller
                last edited by

                @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.

                1 Reply Last reply Reply Quote 1
                • scottalanmillerS
                  scottalanmiller
                  last edited by

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

                  1 Reply Last reply Reply Quote 2
                  • olivierO
                    olivier
                    last edited by

                    "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.

                    1 Reply Last reply Reply Quote 3
                    • KOOLERK
                      KOOLER Vendor
                      last edited by

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

                      scottalanmillerS 1 Reply Last reply Reply Quote 0
                      • scottalanmillerS
                        scottalanmiller @KOOLER
                        last edited by

                        @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.

                        KOOLERK 1 Reply Last reply Reply Quote 0
                        • KOOLERK
                          KOOLER Vendor @scottalanmiller
                          last edited by

                          @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?

                          scottalanmillerS 1 Reply Last reply Reply Quote 0
                          • scottalanmillerS
                            scottalanmiller @KOOLER
                            last edited by

                            @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.

                            KOOLERK 1 Reply Last reply Reply Quote 1
                            • KOOLERK
                              KOOLER Vendor @scottalanmiller
                              last edited by

                              @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!

                              1 Reply Last reply Reply Quote 0
                              • scottalanmillerS
                                scottalanmiller
                                last edited by

                                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.

                                KOOLERK DashrenderD 2 Replies Last reply Reply Quote 1
                                • KOOLERK
                                  KOOLER Vendor @scottalanmiller
                                  last edited by

                                  @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 😉

                                  1 Reply Last reply Reply Quote 1
                                  • stacksofplatesS
                                    stacksofplates
                                    last edited by stacksofplates

                                    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.

                                    1 Reply Last reply Reply Quote 0
                                    • DashrenderD
                                      Dashrender @scottalanmiller
                                      last edited by

                                      @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?

                                      scottalanmillerS 1 Reply Last reply Reply Quote 0
                                      • scottalanmillerS
                                        scottalanmiller @Dashrender
                                        last edited by

                                        @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."

                                        1 Reply Last reply Reply Quote 2
                                        • DashrenderD
                                          Dashrender
                                          last edited by

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

                                          scottalanmillerS 1 Reply Last reply Reply Quote 0
                                          • scottalanmillerS
                                            scottalanmiller @Dashrender
                                            last edited by

                                            @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.

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post