The subvolume was mounted with the user_subvol_rm_allowed option, and now it is possible to create and remove snapshots as a non-root user.
I ran
podman run -d \
--name urbackup \
-e PUID=0 \
-e PGID=0 \
-v $URBACKUP_BACKUPS:/backups \
-v $URBACKUP_DB:/var/urbackup \
--network host \
--cap-add SYS_ADMIN \
uroni/urbackup-server:latest-btrfs
So, it maps the in-container root to my host’s plain user ID.
The podman exec -it urbackup urbackup_snapshot_helper test command passed successfully, with the following output:
Testing for btrfs...
Create subvolume '/backups/testA54hj5luZtlorr494/A'
Create snapshot of '/backups/testA54hj5luZtlorr494/A' in '/backups/testA54hj5luZtlorr494/B'
Delete subvolume 313 (commit): '/backups/testA54hj5luZtlorr494/A'
Delete subvolume 314 (commit): '/backups/testA54hj5luZtlorr494/B'
BTRFS TEST OK
Backups are made with no problem using the btrfs snapshot feature, too. However, when I try to delete any backup via the web panel, I get the following error: Error deleting backup: See server log file for details. The logs contain the following:
ERROR: Could not destroy subvolume/snapshot: Read-only file system
Delete subvolume 315 (commit): '/backups/DESKTOP-F6PKA7S/251225-2127'
ERROR: Error deleting directory "/backups/DESKTOP-F6PKA7S/251225-2127"
ERROR: Directory still exists. Deleting backup failed. Path: "/backups/DESKTOP-F6PKA7S/251225-2127"
As a non-root host user, I can manually change the read-only state of the subvolume btrfs property set ../DESKTOP-F6PKA7S/251225-2127 ro false, and then delete it btrfs subvolume delete ../DESKTOP-F6PKA7S/251225-2127, without any problems. I also tried options like --privileged, --uidmap, --userns in different combinations with no result.
Has anyone managed to do this? Is there any way to make it work properly without using extra scripts or editing the source?
Thanks in advance for any help.