From c8ab0b4421252664554c4ababb6d9b8d74ce2cc2 Mon Sep 17 00:00:00 2001 From: Erik Westrup Date: Wed, 9 Feb 2022 14:04:07 +0100 Subject: [PATCH] iterate --- .../com.github.erikw.restic-automatic-backup.plist | 14 ++++++++++++-- Makefile | 8 +++++++- README.md | 4 ++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Library/LaunchAgents/com.github.erikw.restic-automatic-backup.plist b/Library/LaunchAgents/com.github.erikw.restic-automatic-backup.plist index 92f12f5..e4021a5 100644 --- a/Library/LaunchAgents/com.github.erikw.restic-automatic-backup.plist +++ b/Library/LaunchAgents/com.github.erikw.restic-automatic-backup.plist @@ -8,9 +8,9 @@ com.github.erikw.restic-automatic-backup ProgramArguments - /bin/sh + /bin/bash -c - . /usr/local/etc/restic/erikw.env.sh && /usr/local/bin/restic_backup.sh + source /usr/local/etc/restic/erikw.env.sh && /usr/local/bin/restic_backup.sh RunAtLoad @@ -24,5 +24,15 @@ 0 + EnvironmentVariables + + PATH + /usr/local/bin:/usr/bin:/bin + + + StandardOutPath + /Users/erikw/Library/Logs/restic/restic_stdout.txt + StandardErrorPath + /Users/erikw/Library/Logs/restic/restic_stderr.txt diff --git a/Makefile b/Makefile index 182cc77..62b80d0 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,7 @@ DEST_DIR_CONF = $(PREFIX)/$(DIR_CONF) DEST_DIR_SYSTEMD = $(PREFIX)/$(DIR_SYSTEMD) DEST_DIR_CRON = $(PREFIX)/$(DIR_CRON) DEST_DIR_LAUNCHAGENT= $(HOME)/$(DIR_LAUNCHAGENT) +DEST_DIR_MAC_LOG = $(HOME)/Library/Logs/restic # Destination file targets. DEST_TARGS_SCRIPT = $(addprefix $(PREFIX)/, $(SRCS_SCRIPT)) @@ -124,7 +125,8 @@ install-targets-script: $(DEST_TARGS_SCRIPT) $(BUILD_SRCS_SCRIPT) install-targets-conf: $(DEST_TARGS_CONF) $(BUILD_SRCS_CONF) install-targets-systemd: $(DEST_TARGS_SYSTEMD) $(BUILD_SRCS_SYSTEMD) install-targets-cron: $(DEST_TARGS_CRON) $(BUILD_SRCS_CRON) -install-targets-launchagent: $(DEST_TARGS_LAUNCHAGENT) $(BUILD_SRCS_LAUNCHAGENT) +install-targets-launchagent: $(DEST_TARGS_LAUNCHAGENT) \ + $(BUILD_SRCS_LAUNCHAGENT) $(DEST_DIR_MAC_LOG) # Copies sources to build directory & replace "$INSTALL_PREFIX". $(BUILD_DIR)/% : % @@ -156,3 +158,7 @@ $(DEST_DIR_CRON)/%: $(BUILD_DIR_CRON)/% $(DEST_DIR_LAUNCHAGENT)/%: $(BUILD_DIR_LAUNCHAGENT)/% @${MKDIR_PARENTS} $@ install -m 0444 $< $@ + +# Install destination mac log dir. +$(DEST_DIR_MAC_LOG): + mkdir -p $@ diff --git a/README.md b/README.md index 9b65bbd..758fe8c 100644 --- a/README.md +++ b/README.md @@ -268,8 +268,8 @@ LaunchAgent is the modern service schedulerin in macOS that uses [Launchd](https ```console $ PREFIX=/usr/local make install-launchagent $ vim ~/Library/LaunchAgents/com.github.erikw.restic-automatic-backup.plist # Edit schedule if needed. -$ launchctl load -w ~/Library/LaunchAgents/com.github.erikw.restic-automatic-backup.plist -$ launchctl kickstart gui/501/com.github.erikw.restic-automatic-backup +$ launchctl enable gui/$UID/com.github.erikw.restic-automatic-backup +$ launchctl kickstart -p gui/$UID/com.github.erikw.restic-automatic-backup ```