Rsync Backup Restore to Encrypted Install Failing

Hi All :slight_smile:

I have installed Alma Linux 10.1 without encryption.
I wish to do a backup of my system and then reinstall Alma with encryption.
I would then restore the backup so the only real functional difference is the encryption.

My current steps:
1.On original machine, update kernel to latest:
dnf upgrade

2.On live usb, format the backup drive:

sudo parted /dev/sda --script \
mklabel gpt \
mkpart xfs-root 0% 25% \
mkpart xfs-home 25% 100%

mkfs.xfs /dev/sda1
mkfs.xfs /dev/sda2

3.On live usb, copy over data using rsync:

sudo rsync -aAXvh --progress --delete --sparse \
 --exclude={".cache","/dev/","/proc/","/sys/","/tmp/","/run/","/mnt/","/media/","/boot/"} orig-root/ backup-root/
rm backup-root/etc/{fstab,crypttab}

sudo rsync -aAXvh --progress --delete --sparse orig-home/ backup-home/

4.Install new Alma with encryption.

5.On new machine, update kernel to latest:
dnf upgrade

6.On live usb, restore backup of original machine to new encrypted install:

udisksctl unlock -b /dev/nvme1n1p3
sudo rsync -aAXvh --progress backup-root orig-root
sudo rsync -aAXvh --progress backup-home orig-home

On boot, I get a “a start job is running for dev-disk-by…” and it just hangs on the /home partition. I have checked /etc/fstab has correct blkid, and / is mounted correctly as I can exclude /home from /etc/fstab and it boots. So, I’m not really sure what’s going on?

I have followed this procedure on an Ubuntu system with success. So, I’m not sure if it has something to do with LVMs or XFS being involved vs plain partitions and EXT4 in Ubuntu.

Any help would be greatly appreciated. Thanks!

I have very limited knowledge about both encryption and XFS, but why not just make a fresh install with encryption and same username, boot it, and THEN just rsync /home/username?
I don’t think there should be any problem with rsyncing even if you are logged in to that user.

I see no reason for you to backup /. All settings for userspace is in /home anyway right? Applications should IMHO be installed fresh, so make a list of installed applications and just install them on the new install.

I suppose you can make a list of installed packages with something like

dnf list --installed | awk '{print $1}' > packages.txt

But that would include ALL packages, maybe not what you want.

(pausing writing this post to do some research)
I just started learning dnf, never used it before, only apt and pacman, but a quick search gave me:

dnf repoquery --userinstalled

That will give you manually installed packages, but it includes version number, but when checking my rpi (that is the only one I am running AlmaLinux on) all packages had naming convention <package>-0:<version><arch>, not sure what the 0: stands for, but they all had that so on my install I could use:

dnf repoquery --userinstalled | sed 's,-0.*,,g' > packages.txt

And that would give a list of all manually installed packages in the file that can then be used to install with:

sudo dnf install $(cat packages.txt)

Note that the arch will be removed with the sed line, so if that is important, you could just remove the sed and edit the txt file manually, you cant have THAT many packages manually installed.

Good luck and hope this helps.