0

I have an Ubuntu 22.04.5 server (Server A) that I want to fully clone to another server (Server B) in such a way that Server B becomes an exact replica of Server A (system files, configurations, data, etc.) without requiring any further manual reconfiguration.

Do you know the exact rsync command on how to do that without any conflicting?

The current datacenter doesn't allow booting the current server up from clonezilla iso file.

2 Answers 2

0

First of all, you need to take that when cloning a server, additional manual reconfiguration will be REQUIRED.

First, I recommend to install the same OS on the new server as on the original one, and copying the network settings files, disk mounts config, mdadm settings if used, etc.

After that, boot both the original server and the target server into rescue (LiveCD) and mount the disks, for example, in /mnt. If you use different disk partitions for boot, home, etc., you need to mount the entire hierarchy.

Start copying data on the SOURCE with the command:

rsync -avHAXP --delete --numeric-ids /mnt/ root@TARGET_IP:/mnt/ 

TARGET_IP here is a new server IP. This will copy the files from the original server to the new one, removing any extra files.

After copying on the new server you will need:

  • Set network settings.
  • Correct /etc/fstab.
  • Update mdadm config, if used.
  • Replace the old IP address with a new one in the service settings, like nginx.
  • Update bootloader (grub, lilo, systemd-boot or what you use).
  • Other.

Use the data from the backup of the clean OS configs that I recommended creating above.

Here a lot depends on what is installed in the OS and how it is configured, and it is not possible to provide for all options.

After the settings are done, try to boot the new server into the OS. I recommend using IPMI/KVM to monitor what is happening on the server screen.

0

This kind of exercise is a lot simpler if you handle all your configuration using an orchestration tool; simply build the new host using the same recipe then clone the data and move that across. But that does not appear to be where you are starting from. If this is something you need to do regularly you might consider that.

You didn't mention physical access - simplest solution here would be to swap the disks over.

As for doing this remotely from a host which does not have a well defined build mechanism, starting with rsync is not going to make your life easier. The quickest way to achieve this would be with clonezilla. You may encounter issues if the target host is using different hardware - although the OS will likely load the drivers, depending on the configuration, name changes may mean that the config from the old machine is not going to work on the new machine. This is another reason for going down the virtualization route.

The current datacenter doesn't allow booting the current server up from clonezilla iso file.

Change your datacentre. Seriously. This is a MAJOR red flag. If you have dedicated hardware in a datacentre you cannot manage then something is very wrong. It also implies that you may not have the access to achieve your goal by any means OTHER than as a manual exercise.

It also implies that you don't have the control over the network to handle this operation in a clean way - if you copy over the same config, you will be copying over the IP address(es). That means you can't have both machines up at the same time. You need to plan for how you will access the old host after the new one is started with the copied config. Simplest way to do this would be to change the IP address on the source after copying the data but before the restart of the new host.

Assuming that there may be valid reasons why you can't resolve this in a SENSIBLE way....

First, configure your storage manually to match that on the source machine. NB, if you are using iSCSI here I would not go down this road. Ever. It's technically possible, but a world of pain.

Next replicate the package software across the nodes. There are various ways of doing this, but you should expect a lot of pain if the source machine is not fully up to date with patches. You might try using apt-clone (this is not part of the base apt package).

Next copy over your users - /etc/passwd, group & shadow. You will should also need to copy over any PAM customization (/etc/pam.d). If you have anything anything other than the base configuration for the nameservice (i.e. LDAP) then configure this manually on the target.

Then you can copy over the data. Note that most DBMS will require that you shut down the database before copying (some provide a slow and slightly risky crash recovery process). Rsync is fine here.

My answer here does not go into a lot of depth, and there are a huge number of variables. But its impossible to provide step-step instructions without knowing EXACTLY the source, destination hardware, what the config is and how the host and its software are currently configured - and that is WAY beyond the scope of Q&A here.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.