From 48f28ef3e78eadebd9dcd4698d9a9e78866122f9 Mon Sep 17 00:00:00 2001 From: Sam Scholten Date: Fri, 27 Feb 2026 09:41:28 +1000 Subject: v1.5: Add WSL2 systemd user session support --- CHANGELOG.md | 8 ++++++++ Makefile | 30 ++++++++++++++++++++++-------- VERSION | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2523f92..724321f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +drestic (1.5) stable; urgency=medium + + * Fixed: WSL2 systemd user session support with automatic runtime directory recreation + * Added: fix-wsl target to auto-fix /run/user/UID on WSL restarts + * Improved: User-scope targets (status, backup-now, check-now, logs, config) now work reliably on WSL + + -- Sam Thu, 27 Feb 2026 00:00:00 +1000 + drestic (1.4.1) stable; urgency=high * Fixed: update.sh now properly replaces service file placeholders (was causing '/path/to/be/replaced' execution errors) diff --git a/Makefile b/Makefile index 795daed..42dade6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all test-local format lint clean help test-remote test-remote-setup test-remote-run test-remote-verify test-remote-teardown setup-user setup-system backup-now backup-now-system check-now check-now-system status status-system snapshots snapshots-system recover uninstall-user uninstall-system update upgrade update-gotify update-gotify-user update-gotify-system validate-config logs logs-system config test-update-gotify +.PHONY: all test-local format lint clean help test-remote test-remote-setup test-remote-run test-remote-verify test-remote-teardown setup-user setup-system backup-now backup-now-system check-now check-now-system status status-system snapshots snapshots-system recover uninstall-user uninstall-system update upgrade update-gotify update-gotify-user update-gotify-system validate-config logs logs-system config test-update-gotify fix-wsl # Default target all: test-local @@ -247,7 +247,7 @@ setup-user: setup-system: @sudo ./setup.sh --scope=system -backup-now: +backup-now: fix-wsl @systemctl --user start restic-backup.service @echo "Backup started. Monitor with: journalctl --user -fu restic-backup.service" @@ -255,7 +255,7 @@ backup-now-system: @sudo systemctl start restic-backup.service @echo "System backup started. Monitor with: sudo journalctl -fu restic-backup.service" -check-now: +check-now: fix-wsl @systemctl --user start restic-check.service @echo "Repository check started. Monitor with: journalctl --user -fu restic-check.service" @@ -263,7 +263,21 @@ check-now-system: @sudo systemctl start restic-check.service @echo "System repository check started. Monitor with: sudo journalctl -fu restic-check.service" -status: +# WSL2 fix: ensure /run/user/UID exists for systemd --user +fix-wsl: + @RUNTIME_DIR="/run/user/$(id - u)"; \ + if [ ! -d "$$RUNTIME_DIR" ]; then \ + echo "WSL2: Creating missing $$RUNTIME_DIR..."; \ + sudo mkdir -p "$$RUNTIME_DIR" && \ + sudo chmod 700 "$$RUNTIME_DIR" && \ + sudo chown "$(id -un):$(id -gn)" "$$RUNTIME_DIR"; \ + sudo systemctl start "user@$(id - u).service" 2>/dev/null || true; \ + export XDG_RUNTIME_DIR="$$RUNTIME_DIR"; \ + export DBUS_SESSION_BUS_ADDRESS="unix:path=$${RUNTIME_DIR}/bus"; \ + (sleep 2 && systemctl --user daemon-reexec) 2>/dev/null || true; \ + fi + +status: fix-wsl @echo "=== User Timer Status ===" @systemctl --user status restic-backup.timer restic-check.timer --no-pager || true @echo "" @@ -445,7 +459,7 @@ validate-config: exit 1; \ fi -logs: +logs: fix-wsl @echo "=== Recent User Backup Logs ===" @journalctl --user -u restic-backup.service --since "7 days ago" --no-pager || echo "No recent backup logs found" @@ -453,7 +467,7 @@ logs-system: @echo "=== Recent System Backup Logs ===" @sudo journalctl -u restic-backup.service --since "7 days ago" --no-pager || echo "No recent backup logs found" -config: +config: fix-wsl @echo "=== DRestic Configuration Status ===" @if [ -f ~/.config/restic/env ]; then \ echo "User scope configuration:"; \ @@ -462,7 +476,7 @@ config: echo " Environment file: ~/.config/restic/env"; \ echo " Paths file: ~/.config/restic/paths"; \ echo " Excludes file: ~/.config/restic/excludes"; \ - echo " Timer status: $$(systemctl --user is-active restic-backup.timer 2>/dev/null || echo 'inactive')"; \ + echo " Timer status: $(systemctl --user is-active restic-backup.timer 2>/dev/null || echo 'inactive')"; \ elif sudo [ -f /root/.restic_env ]; then \ echo "System scope configuration:"; \ echo " Config directory: /etc/restic/"; \ @@ -470,7 +484,7 @@ config: echo " Environment file: /root/.restic_env"; \ echo " Paths file: /etc/restic/paths"; \ echo " Excludes file: /etc/restic/excludes"; \ - echo " Timer status: $$(sudo systemctl is-active restic-backup.timer 2>/dev/null || echo 'inactive')"; \ + echo " Timer status: $(sudo systemctl is-active restic-backup.timer 2>/dev/null || echo 'inactive')"; \ else \ echo "No DRestic configuration found."; \ echo "Run 'make setup-user' or 'make setup-system' to get started."; \ diff --git a/VERSION b/VERSION index 428b770..c239c60 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.3 +1.5 -- cgit v1.2.3