1

I ordered a faster Hetzner root server to move my XEN mashine there with all volume groups, lvm-volumes and VMs.

I already started to create the same xen VMs there, copy config files and userdata and install the same packages as in the old VMs, but that is a lot of work.

Isn there an easy way to actually copy everything on the basic root level, including all partitions on the raid 1, so I get an exact copy of my old server?

Then I would only have to adapt the IPs from a root console and I would be done

1 Answer 1

1

xenA: Your previous server

xenB: Your new server

Step1: Boot both server with a live linux dist(Ubuntu,Fedaora, CentOS)

Step2: Start ssh service in your new server

Step3: In xenA execute the command below

dd if=/dev/sdX bs=16M | pv |  ssh user@xenB dd of=/dev/sdX

Where X represents the local disks attached to the servers. You can find them wiht "lsblk" command.

Note: pv is used for monitorng the data.

Step4: Modify the IP adress and all the other parameters which are changed.

With this method you do not need to worry about partitions, lvm volumes and the filesystem above.

Hope that this method address your question.

1. Step: Boot the Boot in to single mode by changing boot parameter: "vga=785 splash" with linux single. You can find the screenshots from the link below.

https://support.citrix.com/article/CTX116019#Resetting%20Password%20in%20XenServer%20Versions%205.0%20and%20Later

  1. Step: Start the network service on your host with single user mode and transfer the exact block device to another machine.
 dd if=/dev/sda bs=16M |  ssh user@backuphost dd of=backup.img 

You can find detailed info in terms of compression below:

Well there are multiple methods to achive this goal.

  1. dd and netcat WARNING: This method expose your data on internet trading the time consumption.

If you are able to boot the system with single user or another live image you can use the dd method for the exact copy of your server,it is mandatory to stop all services and vms in order to ensure data integrity:

  • Prepare a backup host by executing the command below, (use screen or tmux or make the command to fork background if you are working with a remote backup host to avoid ssh timeouts)
nc -l RANDOMPORTNUMBER|bzip2 -d|dd bs=16M of=backup.img
  • On your vm host you can execute the command below in order clone your exact host
dd bs=16M if=/dev/sda|bzip2 -c|nc ipaddressofbackuphost RANDOMPORTNUMBER
  1. tar and ssh I personally prefer this method to to back up my remote machines when needed. This method does not directly expose your data to public network since it uses ssh.

One another reason that i prefer this method is since the backup will be done in file level, the empty spaces and block devices which are not needed to be backed up are excluded,where we save storage and traffic. Since you declared that you want an exact clone I had to talk about the first method.

Please do not forget to modify the excluded mount points according to your distribution and the application. You have to consider that if you are charged by your storage and traffic amount.

cd / # THIS CD IS IMPORTANT THE FOLLOWING LONG COMMAND IS RUN FROM /
tar -cvpzf backup.tar.gz \
--exclude=/backup.tar.gz \
--exclude=/proc \
--exclude=/tmp \
--exclude=/mnt \
--exclude=/dev \
--exclude=/sys \
--exclude=/run \ 
--exclude=/media \ 
--exclude=/var/log \
--exclude=/var/cache/apt/archives \
--exclude=/usr/src/linux-headers* \ 
--exclude=/home/*/.gvfs \
--exclude=/home/*/.cache \ 
--exclude=/home/*/.local/share/Trash / | ssh <backuphost> "( cat > ssh_backup.tar.gz )"

Here you can find further detailed information about the topic:

4
  • Sure, i don't need to copy the unused nullbytes. With"backup host" you mean my new server? And how do I continue with the backup.gz file on the new server?
    – rubo77
    Commented Mar 20, 2020 at 9:03
  • I think with lvm it might be a bit more complicated, since I want to copy all positions
    – rubo77
    Commented Mar 20, 2020 at 9:05
  • with the tar method all you have to do is make exact same partition table with your new server, and tar xvfz to / if you properly exclude the mount points which are necessity. Also you need to updat initramfs. I believe in your case dd would be better. Please provide how you access to your xenserver host? Is it a physical machine or a virtual machine?
    – hncr
    Commented Mar 20, 2020 at 9:28
  • @rubo77 I just checked your server provider and it seems they are providing IPMI access to you to manage your server. If I were you I would go for xen live migration with using xen tools instead of cloning all the machine. This way you will be working with only vms. If you are not experienced and the systems are on production, it is always better to use software vendor's tools rather than ssh,dd,nc...
    – hncr
    Commented Mar 20, 2020 at 9:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .