Backing up systemd-homed images causes severe hangs

Hi there!

I thought about first posting here before opening an issue for the project.

So I am using Systemd’s Homed functionality.
It basically stores the user’s home directory as a disk image and it is mounted as a loopback device on authentication.

This is a very nice technology as it provides further security, portability and out of the box options for FIDO2 authentication for instance. However as it is not shipped by default, most Linux users do not even know it exists.

It actually plays together well with Kopia, all I have to back up are the image files for the user. A version of this backed up file fully describes the user.

However, there is 1 problem: when Kopia reads this file, it actually causes hard stuttering for anything which reads or writes to this looped back files when the user is logged in or tries to log in.

As I automate my backups, I have not really found a sensible solution to “dodge” the user being logged in. So rather then trying to find a workaround, I would like to get to the bottom of this.

I am using btrfs as a backing storage for the images (the partition itself the images are stored on are encrypted as well) and the images are use btrfs as well, encrypted via LUKS.

Is this problem caused by Kopia being too “agressive” and causing deadlocks? Or is this a combination of everything I use? I would like to point out that this only occours when backing up these homed images, otherwise not.

I am not really sure, so if anybody has ideas and are willing to uncover and help fix it I am happy to work together just reply to the post to get started or if you are simply curious or maybe are in the same/similar situation.

Why to read file which is in use? Obviously you have then multiple programs competing for access to it. And even more important how you can ensure your backup integrity when working like this? (this file can change half way during your backup).

I would think than obvious solution is to run kopia backup against “home file” file system snapshot. You mentioned that you are using BTRFS so it should be very straightforward to implement and kopia nicely supports it via actions.

This is the reason for it. The best way would be to somehow make sure that the given user to be backed up is not logged in and prevent login via some lock mechanism if the backup is not completed.