Migration from One Server to Another

  • I just upgraded from a 2018 or 19 offer to a 2020 offer.... All better than previous (current) server except less storage.


    I dont want to have to set up everything from scratch again so whats the best way to clone my Ubuntu 18.04.5 LTS system to the new box and then retire my old server? Assume low level of knowledge of Linux please when advising me!! ;)


    Thanks

  • I don‘t have the commands at hand but you should find a suitable tutorial easily if you search for them.


    You just boot both servers in the rescue system and use dd to transfer the data through an ssh tunnel. It does sound very complicated but it‘s just a oneliner.


    The only thing which is needed is that the target disk of the new system hast to be at least the size of the old system. After the transfer it will be exactly the size (and content) of the old system but you can resize it afterwards.

  • Quote

    Thanks! That works if the new server has LESS storage space???

    No, you need to prepare it, as the command only works if you have the same or more storage space.


    So say, your current server has 40Gb and you want to migrate to an 20Gb server. Therefore you first need to reduce your partitions down to less than 20Gb (i would suggest 18Gb). You can use parted or (if you have graphics) gparted for this job. Then can use the above command to copy the contents. It will fail at some point, but that is ok, as you have ensured with parted that all your data is in the first 18Gb of the harddisk (or you can add bs=1Gb count=19 instead of bs=32M to stop after 19Gb have been copied). Then you start the new server and use parted to expand your 18Gb partition to the full 20Gb disk space.


    Sincerely 7c00

  • Thanks... well I failed already as I cannot type | in the damn VNC screen window.. and can't login to old server with SSH as its in Rescue mode and root password (given by Netcup controlpanel) does not work. It ISNT straightforward


    EDIT: Right resized, found | on the # key where ~ is the shifted character... Great!? Now try again

  • Quote

    well I failed already as I cannot type | in the damn VNC screen window

    It works fine for me, but this may be due to different keyboard layouts (i have a German one).

    You may try the display keyboard (button on the top left). There you can type | by using Alt Gr and the key next to the left shift key.

  • Thanks, well I am assuming (probably killing years of work) that its /dev/sda rather than /dev/vda since there is no such device on my server


    And we are finally off (after typing correct root password MANY times only to be told it was wrong.. I bypassed that by using VNC to set a new plain text simple password)... and we're running in Putty+SSH rather than VNC which was a nightmare....


    Then presumably I just need to adjust my DNS/MX records or whatever point my domain to this server and i should be good...!

  • I guess I need to edit /etc/fstab to put correct UUID in but I cannot get that as blkid doesn't give me it (from Busybox). I also have no vi/nano to do the edit.


    Is this something I can get to via the Rescue mode and do edit etc there?

  • This seems weird, as the UUID shouldn't change if you've copied the partitions exactly.


    Of course you can use the rescue system to check for the error. Just look up your partitions and mount them to /mnt or somewhere else. Then you can inspect the files and change them if necessary.


    I would also advise you to look into the grub.cfg (somewhere in /boot, but probably it is located on another smaller partition and mounted to the final linux to the /boot directory). This file should also contain an UUID for the root partition.

  • Thanks 7c00 but clearly I have mucked something up. It's ALL a complete mess now...


    My old server (resized partition to bring the contents under 480GB) is broken. It boots from Grub but reports file system errors and says to run fsck on /dev/sda3


    I run fsck /dev/sda3 and that says superblock checksum does not match superblock, tries backup blocks and then reports errors eg Error writing block 80740353 (Invalid argument) Ignore Error (y/n). No doesnt fix it and neither does Yes....


    Now I have NO working servers...

  • My old server (resized partition to bring the contents under 480GB) is broken. It boots from Grub but reports file system errors and says to run fsck on /dev/sda3

    Did you use parted to resize the partition? If yes, then parted seemed to just change the partition table and not resized the fs (i always use gparted, which does this, so I thought that parted should do the same). I would suggest to resize the partition on the old server back to it's original size (so the partition table is like before) and see, if you can access your data.

  • Quote

    resizepart partition end

    Change the end position of partition. Note that this does not modify any filesystem present in the partitio

    Damned, why is GParted called a GUI of parted, when it does those things by itself. I'm so sorry;(.


    But lets focus on getting the partition back... Parted knows percentages, so you should be able to just give all unallocated space back to the partition using "parted /dev/sda resizepart [partition number] 100%" (based on https://unix.stackexchange.com…e-using-parted-in-batch-m).


    P.S.: Don't use resize2fs (yet), as this will modify the actual data on the harddisk. We only want to change the partition table to fully encapsulate the old filesystem (if the partition is greater, it shouldn't matter, but currently it is smaller, which looks like to the filesystem, as if it was cut in half).

  • I've given up... I'm just building the new server from scratch but any clever ideas that would help me resuirrect old one would at least let me get access back to configs and check and make sure I dont get anything wrong on new one.


    So I just want to be able to get the /dev/sda3 back and accessible by SSH

  • First I would suggest to try to rescue the partition table: https://www.gnu.org/software/p…ual/html_node/rescue.html

    If this doesn't make anything better, we can use the file recovery utilities: https://wiki.archlinux.org/ind…ery#Testdisk_and_PhotoRec


    As you don't want to touch the filesystem on the old server, you need to get some external storage (I would suggest from the new server), where the tools can put the recovered data. I would suggest SSHFS: https://wiki.archlinux.org/index.php/SSHFS