On the test, I will give an example of a primitive copying of the Ubuntu Server system into the archive and recovery on the same system or on a clean new one.
Create an archive with a backup copy of the disk root, excluding unnecessary directories and the archive itself:
sudo tar cvpzf /backup.tgz --exclude=/media --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
To restore to the same or clean only installed system, check whether there is enough free space:
If the server is different with a clean system, create a directory and copy into it a copy of the /boot directory with the loader and the file /etc/fstab:
sudo mkdir /OLD sudo cp -R /boot/ /OLD/ sudo cp /etc/fstab /OLD/
Being in the directory with the archive we will unpack it with preserving the rights to files on top of the system:
sudo tar xvpfz backup.tgz -C /
Return the /boot directory and the fstab file:
sudo cp -R /OLD/boot/ /boot/ sudo cp /OLD/fstab /etc/fstab
Make sure that the copying was successful and the correct UUID is specified in the /boot/grub/grub.cfg and /etc/fstab files, you can see the UUID of partitions on the current system with the command:
lsblk -o NAME,UUID
Reboot the system:
With such a recovery to another server, you may have to slightly change the system configuration, for example, if the new server has network interfaces in other slots and have a different name, etc.
See also my article:
Transferring a running Ubuntu system to another disk