feat: Add btrfs-assistant to easily configure automatic snapshots of /home (#1459)

* feat: include btrfs-assistant and include a default config-template
We are providing a default config meant to be used with `sudo snapper create-config /var/home` so it will work with the automatic snapper systemd units that btrfs-assistant configures.

snapshotting / is pretty pointless on ostree so the root config points to /var/home instead.

* fix: launch btrfs-assistant in xwayland to avoid a bug with xdg-document-portal

* feat: add snapper-setup script
does not touch anything if user has already configured snapper

* fix: patch btrfs-assistant-launcher to not pass XDG_RUNTIME_DIR
This will make it run in xwayland instead

* chore: set sane defaults for snapshotting $HOME
This commit is contained in:
HikariKnight 2024-10-26 08:44:14 +02:00 committed by GitHub
parent 959e9cad8f
commit c23cca08ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 80 additions and 0 deletions

View File

@ -421,6 +421,7 @@ RUN --mount=type=cache,dst=/var/cache/rpm-ostree \
ydotool \
yafti \
stress-ng \
btrfs-assistant \
lsb_release && \
rpm-ostree install \
ublue-update && \
@ -430,6 +431,7 @@ RUN --mount=type=cache,dst=/var/cache/rpm-ostree \
sed -i 's/max_cpu_load_percent.*/max_cpu_load_percent = 100.0/' /etc/ublue-update/ublue-update.toml && \
sed -i 's/max_mem_percent.*/max_mem_percent = 90.0/' /etc/ublue-update/ublue-update.toml && \
sed -i 's/dbus_notify.*/dbus_notify = false/' /etc/ublue-update/ublue-update.toml && \
sed -i 's/ --xdg-runtime=\\"${XDG_RUNTIME_DIR}\\"//g' /usr/bin/btrfs-assistant-launcher && \
curl -Lo /usr/bin/installcab https://raw.githubusercontent.com/KyleGospo/steam-proton-mf-wmv/master/installcab.py && \
chmod +x /usr/bin/installcab && \
curl -Lo /usr/bin/install-mf-wmv https://github.com/KyleGospo/steam-proton-mf-wmv/blob/master/install-mf-wmv.sh && \
@ -720,6 +722,7 @@ RUN rm -f /etc/profile.d/toolbox.sh && \
systemctl enable bazzite-hardware-setup.service && \
systemctl disable tailscaled.service && \
systemctl enable dev-hugepages1G.mount && \
systemctl enable bazzite-snapper-setup && \
systemctl --global enable bazzite-user-setup.service && \
systemctl --global enable podman.socket && \
systemctl --global enable systemd-tmpfiles-setup.service && \

View File

@ -0,0 +1,10 @@
[Unit]
Description=Create a default snapper config if snapper is unconfigured
After=local-fs.target
[Service]
Type=oneshot
ExecStart=/usr/libexec/bazzite-snapper-setup
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,4 @@
#!/bin/bash
if ! snapper get-config >/dev/null 2>&1; then
snapper create-config /var/home
fi

View File

@ -0,0 +1,63 @@
# subvolume to snapshot
# With ostree it is pointless to snapshot /,
# so we set the root config to snapshot /var/home instead
SUBVOLUME="/var/home"
# filesystem type
FSTYPE="btrfs"
# btrfs qgroup for space aware cleanup algorithms
QGROUP=""
# fraction or absolute size of the filesystems space the snapshots may use
SPACE_LIMIT="0.5"
# fraction or absolute size of the filesystems space that should be free
FREE_LIMIT="0.2"
# users and groups allowed to work with config
ALLOW_USERS=""
ALLOW_GROUPS=""
# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
# directory
SYNC_ACL="no"
# start comparing pre- and post-snapshot in background after creating
# post-snapshot
BACKGROUND_COMPARISON="yes"
# run daily number cleanup
NUMBER_CLEANUP="yes"
# limit for number cleanup
NUMBER_MIN_AGE="1800"
NUMBER_LIMIT="50"
NUMBER_LIMIT_IMPORTANT="10"
# create hourly snapshots
TIMELINE_CREATE="yes"
# cleanup hourly snapshots after some time
TIMELINE_CLEANUP="yes"
# limits for timeline cleanup
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="8"
TIMELINE_LIMIT_DAILY="4"
TIMELINE_LIMIT_WEEKLY="4"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
# cleanup empty pre-post-pairs
EMPTY_PRE_POST_CLEANUP="yes"
# limits for empty pre-post-pair cleanup
EMPTY_PRE_POST_MIN_AGE="90"