Best way to move/copy a VM/LXC to another Server

  • Hello,


    i would like to ask for some suggestions on what you suggest is the best way to move/copy a VM/LXC to another Server.

    I have a lot of VMs/LXC running and would like to have a copy of them on a 2nd server in case anything happens.

    Additionally if I configure a VM/LXC on my test server I'd like to move/copy it to my productive one without starting from scratch again.



    Every suggestion is more than welcome and I love to have OMV as my virtualization host :)


    Best Regards

    suprstar

  • VM virtual drives are a qcow2 file and lxc's are a directory. I have never moved them to a different system, so this is just thinking of the process, but you can have a look at the cli tool virsh to dump and import the xml config. Then copy the qcow and/or lxc directories to the other system.


    You would need to fix the storage paths and/or device passthroughs in the configs. This should be able to be done by editing the xml or by using a docker install of virt-manager (an example/template is in the compose plugin)

    • Official Post

    Is it possible to have an export/import function for VMs/LXC?

    Import? Maybe. It could get tricky if the plugin was expected to fix paths, network(s), cpu setting, etc.

    Export? Like BernH mentioned, they are already files that just need to be copied. Not sure what else export would do.

    omv 7.7.10-1 sandworm | 64 bit | 6.11 proxmox kernel

    plugins :: omvextrasorg 7.0.2 | kvm 7.1.8 | compose 7.6.10 | cterm 7.8.7 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.3.1


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Hi,


    for export I was thinking of a zip file or tar file where everything is in. So if you import the zip or tar, all the files will be copied to the right place :) .

    I am fully aware that I have to modify some stuff afterwards. Prerequisite, of course, is that the paths are the same on the source and destination.


    So the reason I was asking for import/export is, I do not know which files need to be copied and where they are located. *hint hint* ;)

    • Official Post

    for export I was thinking of a zip file or tar file where everything is in

    This is what VMware does. Their .ova file contains that content.

    So if you import the zip or tar, all the files will be copied to the right place

    The xml file wouldn't be a problem. The qcow files would require selecting a pool to copy to.

    I do not know which files need to be copied and where they are located

    The paths for the qcow files are in the xml which you can view in the plugin's Advanced menu.

    The xml files are stored in /etc/libvirt/qemu/ or you can get them with virsh dumpxml VMNAME.

    That is all there is for a VM.

    omv 7.7.10-1 sandworm | 64 bit | 6.11 proxmox kernel

    plugins :: omvextrasorg 7.0.2 | kvm 7.1.8 | compose 7.6.10 | cterm 7.8.7 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.3.1


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Thank you for the file paths. I will test it.

    I guess there is no equivalent for the .ova file in qemu?

    Is there any other way than to reboot to get the copied VM/LXC into the Services/KVM/VMs list in OMV?

    • Official Post

    I guess there is no equivalent for the .ova file in qemu?

    Not much need to. An .ova is just a zip file with a different extension. Once the ova is extracted, the vmdk files can just be used. A zip file for qemu would work the same way.

    Is there any other way than to reboot to get the copied VM/LXC into the Services/KVM/VMs list in OMV?

    Yep. sudo virsh define /path/to/VMNAME.xml

    omv 7.7.10-1 sandworm | 64 bit | 6.11 proxmox kernel

    plugins :: omvextrasorg 7.0.2 | kvm 7.1.8 | compose 7.6.10 | cterm 7.8.7 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.3.1


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Hi,


    the command worked perfect for a VM but with an LXC there comes an error.


    Code
    root@vm-4-omv7:/etc/libvirt/lxc# virsh define Debian_docker_test.xml 
    error: Failed to define domain from Debian_docker_test.xml
    error: Failed to read pidfile /var/lib/libvirt/qemu/qmp-HXJVL2/qmp.pid: Datei oder Verzeichnis nicht gefunden

    When I restart OMV the LXC is shown and I can start it without any issue.

    I checked if the file exists on the "source" server but it doesn't. No clue where it comes from.

    Do you have an idea?

    • Official Post

    but with an LXC there comes an error.

    Sorry, that wasn't meant for LXC.


    You would need to specify:


    virsh --connect lxc:/// define LXC_NAME.xml

    omv 7.7.10-1 sandworm | 64 bit | 6.11 proxmox kernel

    plugins :: omvextrasorg 7.0.2 | kvm 7.1.8 | compose 7.6.10 | cterm 7.8.7 | cputemp 7.0.2 | mergerfs 7.0.5 | scripts 7.3.1


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • MCno1

    Added the Label resolved

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!