Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should create and set "/etc/urbackup/backupfolder" during container start #3

Open
kcpants opened this issue May 2, 2023 · 3 comments

Comments

@kcpants
Copy link

kcpants commented May 2, 2023

Right now, the start.sh script creates the backupfolder file in /var/urbackup and populates it with the path to the /media directory (which is mapped into the container) in the following code:

# set default location for backup storage to /media
echo "/media" > /var/urbackup/backupfolder

Some urbackup features also rely on this path being set in /etc/urbackup/backupfolder. In particular, in order to enable btrfs snapshots in urbackup, the backup path must be set in /etc/urbackup/backupfolder as described here (quoted below):

In order to create and remove btrfs snapshots UrBackup installs a setuid executable urbackup_ snapshot_helper. UrBackup also uses this tool to test if cross-device reflinks are possible. Only if UrBackup can create cross-device reflinks and is able to create and destroy btrfs snapshots, is the btrfs mode enabled. urbackup_snapshot_helper needs to be told separately where the UrBackup backup folder is. This path is read from /etc/urbackup/backupfolder. Thus, if /media/backup/urbackup is the folder where UrBackup is saving the paths, following commands would properly create this file:

mkdir /etc/urbackup
echo "/media/backup/urbackup" > /etc/urbackup/backupfolder

It's possible to create this file once the container is running and it will persist through restarts, until a new container image is pulled at which point urbackup becomes unable to use btrfs snapshots and falls back on traditional backups until /etc/urbackup/backupfolder is restored.

Workaround

The directory and file can be created alongside the container by adding the following line to the post-args field in advanced settings of the docker container (note the leading semicolon); docker exec binhex-urbackup bash -c "mkdir -p /etc/urbackup; echo '/media' > /etc/urbackup/backupfolder"

@binhex
Copy link
Owner

binhex commented May 2, 2023

thanks for this, changes included in the image and a new image has been built, please pull down latest and let me know if it works ok for you.

@kcpants
Copy link
Author

kcpants commented May 2, 2023

Wow, amazing response time!

I created a new container based on the latest image and confirmed that /etc/urbackup/backupfolder exists and is populated as expected and that if --cap-add SYS_ADMIN is set as an extra parameter and /media is mapped to a single btrfs disk then btrfs snapshots work out of the box:

sh-5.1# urbackup_snapshot_helper test
Testing for btrfs...
Create subvolume '/media/testA54hj5luZtlorr494/A'
Create a snapshot of '/media/testA54hj5luZtlorr494/A' in '/media/testA54hj5luZtlorr494/B'
Delete subvolume (commit): '/media/testA54hj5luZtlorr494/A'
Delete subvolume (commit): '/media/testA54hj5luZtlorr494/B'
BTRFS TEST OK

Thank you!

The fix works for me and probably will work for most people. I did notice that /var/urbackup is symlinked to /config/urbackup meaning that /var/urbackup/backupfolder actually points to /config/urbackup/backupfolder which lives in the appdata directory and is therefore customizable so if anyone has changed /config/urbackup/backupfolder to point to a path other than /media within the container they might still need to use the workaround. Seems unlikely, but to support these folks (if they exist) it may be necessary to make /etc/urbackup/backupfolder customizable in the future as well.

@kcpants
Copy link
Author

kcpants commented May 3, 2023

As mentioned in my comment above, the change in commit 7cf124d is perfect for enabling btrfs snapshots in my urbackup container and it's likely also sufficient for all common urbackup configurations. Feel free to close this issue or leave it open if you'd like to continue tracking making /etc/urbackup/backupfolder configurable (perhaps by symlinking it to /var/urbackup/backupfolder?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants