diff options
| author | Sam Scholten | 2026-02-27 09:41:28 +1000 |
|---|---|---|
| committer | Sam Scholten | 2026-02-27 09:41:28 +1000 |
| commit | 48f28ef3e78eadebd9dcd4698d9a9e78866122f9 (patch) | |
| tree | c3cf295802e3c74057f6ffae8103734ad333e87b /Makefile | |
| parent | 575b40de96ce58521561f916a1d40bfe82014dc7 (diff) | |
| download | drestic-48f28ef3e78eadebd9dcd4698d9a9e78866122f9.tar.gz drestic-48f28ef3e78eadebd9dcd4698d9a9e78866122f9.zip | |
v1.5: Add WSL2 systemd user session supportmain
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -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."; \ |
