diff --git a/Library/LaunchAgents/com.github.erikw.restic-backup.plist b/Library/LaunchAgents/com.github.erikw.restic-backup.plist
index 04d229c..66f0ad3 100644
--- a/Library/LaunchAgents/com.github.erikw.restic-backup.plist
+++ b/Library/LaunchAgents/com.github.erikw.restic-backup.plist
@@ -12,16 +12,16 @@
/bin/bash
-c
- source /usr/local/etc/restic/default.env.sh && /usr/local/bin/restic_backup.sh >>$HOME/$LOG_OUT 2>>$HOME/$LOG_ERR
+ source $INSTALL_PREFIX/etc/restic/default.env.sh && $INSTALL_PREFIX/bin/restic_backup.sh >>$HOME/$LOG_OUT 2>>$HOME/$LOG_ERR
EnvironmentVariables
PATH
- /usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
+ $INSTALL_PREFIX/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
LOG_OUT
- /Library/Logs/restic/backup-stdout.log
+ /Library/Logs/restic/backup_stdout.log
LOG_ERR
- /Library/Logs/restic/backup-stderr.log
+ /Library/Logs/restic/backup_stderr.log
RunAtLoad
diff --git a/Library/LaunchAgents/com.github.erikw.restic-check.plist b/Library/LaunchAgents/com.github.erikw.restic-check.plist
new file mode 100644
index 0000000..a0e1899
--- /dev/null
+++ b/Library/LaunchAgents/com.github.erikw.restic-check.plist
@@ -0,0 +1,37 @@
+
+
+
+
+ Label
+ com.github.erikw.restic-check
+ ProgramArguments
+
+ /bin/bash
+ -c
+ source $INSTALL_PREFIX/etc/restic/default.env.sh && $INSTALL_PREFIX/bin/restic_check.sh >>$HOME/$LOG_OUT 2>>$HOME/$LOG_ERR
+
+ EnvironmentVariables
+
+ PATH
+ $INSTALL_PREFIX/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
+ LOG_OUT
+ /Library/Logs/restic/check_stdout.log
+ LOG_ERR
+ /Library/Logs/restic/check_stderr.log
+
+ RunAtLoad
+
+
+ StartCalendarInterval
+
+
+ Day
+ 1
+ Hour
+ 20
+ Minute
+ 0
+
+
+
+
diff --git a/Makefile b/Makefile
index 934c0a0..3802f6c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,3 @@
-# TODO add install for launchagent completely, and unisntall target using bootstrap?
#### Notes ####################################################################
# This build process is done in three stages (out-of-source build):
# 1. copy source files to the local build directory.
@@ -20,7 +19,8 @@
install-targets-script install-targets-conf install-targets-systemd \
install-targets-cron install-targets-launchagent \
install-targets-schedtask uninstall-targets-schedtask \
- activate-launchagent deactivate-launchagent
+ activate-launchagent-backup deactivate-launchagent-backup \
+ activate-launchagent-chec deactivate-launchagent-check
#### Macros ###################################################################
NOW := $(shell date +%Y-%m-%d_%H:%M:%S)
@@ -52,8 +52,10 @@ MKDIR_PARENTS=sh -c '\
# LaunchAgent names.
UID := $(shell id -u)
-LAUNCHAGENT = com.github.erikw.restic-backup
-LAUNCHAGENT_TARGET = gui/$(UID)/$(LAUNCHAGENT)
+LAUNCHAGENT_BACKUP = com.github.erikw.restic-backup
+LAUNCHAGENT_CHECK = com.github.erikw.restic-check
+LAUNCHAGENT_TARGET_BACKUP = gui/$(UID)/$(LAUNCHAGENT_BACKUP)
+LAUNCHAGENT_TARGET_CHECK = gui/$(UID)/$(LAUNCHAGENT_CHECK)
# What to substitute $INSTALL_PREFIX in sources to.
# This can be useful to set to empty on commandline when building e.g. an AUR
@@ -126,6 +128,9 @@ DEST_TARGS_SYSTEMD = $(addprefix $(PREFIX)/, $(SRCS_SYSTEMD))
DEST_TARGS_CRON = $(addprefix $(PREFIX)/, $(SRCS_CRON))
DEST_TARGS_LAUNCHAGENT = $(addprefix $(LAUNCHAGENTDIR)/, $(SRCS_LAUNCHAGENT))
+DEST_LAUNCHAGENT_BACKUP = $(DEST_DIR_LAUNCHAGENT)/$(LAUNCHAGENT_BACKUP).plist
+DEST_LAUNCHAGENT_CHECK = $(DEST_DIR_LAUNCHAGENT)/$(LAUNCHAGENT_CHECK).plist
+
INSTALLED_FILES = $(DEST_TARGS_SCRIPT) $(DEST_TARGS_CONF) \
$(DEST_TARGS_SYSTEMD) $(DEST_TARGS_CRON) \
$(DEST_TARGS_LAUNCHAGENT)
@@ -158,10 +163,14 @@ install-systemd: install-targets-script install-targets-conf \
# target: install-cron - Install cron setup.
install-cron: install-targets-script install-targets-conf install-targets-cron
-# target: install-launchagent - Install LaunchAgent setup.
+# target: install-launchagent - Install backup LaunchAgent setup.
install-launchagent: install-targets-script install-targets-conf \
install-targets-launchagent
+# target: install-launchagent-check - Install check LaunchAgent setup.
+# Intended to be run after install-launchagent, thus not requiring scripts/conf
+#install-launchagent: install-targets-launchagent
+
# target: install-schedtask - Install Windows ScheduledTasks
install-schedtask: install-targets-script install-targets-conf \
install-targets-schedtask
@@ -218,12 +227,22 @@ $(DEST_DIR_LAUNCHAGENT)/%: $(BUILD_DIR_LAUNCHAGENT)/%
$(DEST_DIR_MAC_LOG):
mkdir -p $@
-# target: activate-launchagent - Activate the LaunchAgent.
-activate-launchagent:
- launchctl bootstrap gui/$(UID) $(DEST_TARGS_LAUNCHAGENT)
- launchctl enable $(LAUNCHAGENT_TARGET)
- launchctl kickstart -p $(LAUNCHAGENT_TARGET)
+# target: activate-launchagent-backup - Activate the backup LaunchAgent.
+activate-launchagent-backup:
+ launchctl bootstrap gui/$(UID) $(DEST_LAUNCHAGENT_BACKUP)
+ launchctl enable $(LAUNCHAGENT_TARGET_BACKUP)
+ launchctl kickstart -p $(LAUNCHAGENT_TARGET_BACKUP)
-# target: deactivate-launchagent - Deactivate and remove the LaunchAgent.
-deactivate-launchagent:
- launchctl bootout $(LAUNCHAGENT_TARGET)
+# target: activate-launchagent-check - Activate the check LaunchAgent.
+activate-launchagent-check:
+ launchctl bootstrap gui/$(UID) $(DEST_LAUNCHAGENT_CHECK)
+ launchctl enable $(LAUNCHAGENT_TARGET_CHECK)
+ launchctl kickstart -p $(LAUNCHAGENT_TARGET_CHECK)
+
+# target: deactivate-launchagent-backup - Remove the backup LaunchAgent.
+deactivate-launchagent-backup:
+ launchctl bootout $(LAUNCHAGENT_TARGET_BACKUP)
+
+# target: deactivate-launchagent-check - Remove the check LaunchAgent.
+deactivate-launchagent-check:
+ launchctl bootout $(LAUNCHAGENT_TARGET_CHECK)
diff --git a/README.md b/README.md
index 7a63218..2d4840e 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ Depending on your system, the setup will look different. Choose one of:
Many Linux distributions nowadays use [Systemd](https://en.wikipedia.org/wiki/Systemd), which features good support for running services and scheduled jobs. If your distribution is no on Systemd, check out the [cron setup](#setup-cron) instead.
**TL;DR setup**
-1. [Create](#1-create-backblaze-b2-account-bucket-and-keys) B2 bucket + credentials
+1. [Create](#1-create-backblaze-b2-account-bucket-and-keys) B2 bucket + credentials
1. Install scripts, configs systemd units/timers:
* With `make`:
```console
@@ -114,7 +114,7 @@ Many Linux distributions nowadays use [Systemd](https://en.wikipedia.org/wiki/Sy
[Launchd](https://www.launchd.info/) is the modern built-in service scheduler in macOS. It has support for running services as root (Daemon) or as a normal user (Agent). Here we set up an LauchAgent to be run as your normal user for starting regular backups.
**TL;DR setup**
-1. [Create](#1-create-backblaze-b2-account-bucket-and-keys) B2 bucket + credentials
+1. [Create](#1-create-backblaze-b2-account-bucket-and-keys) B2 bucket + credentials
1. Install scripts, configs and LaunchAgent:
* (recommended) with Homebrew from the [erikw/homebrew-tap](https://github.com/erikw/homebrew-tap):
```console
@@ -135,17 +135,17 @@ Many Linux distributions nowadays use [Systemd](https://en.wikipedia.org/wiki/Sy
* Homebrew install: `~/Library/LaunchAgents/homebrew.mxcl.restic-automatic-backup-scheduler.plist`.
* `make` install: `~/Library/LaunchAgents/com.github.erikw.restic-backup.plist`.
1. Enable automated backup for starting with the system & make the first backup:
- * Homebrew install:
+ * Homebrew install:
```console
$ brew services start restic-automatic-backup-scheduler
```
- * `make` install:
+ * `make` install:
```console
$ launchctl bootstrap gui/$UID ~/Library/LaunchAgents/com.github.erikw.restic-backup.plist
$ launchctl enable gui/$UID/com.github.erikw.restic-backup
$ launchctl kickstart -p gui/$UID/com.github.erikw.restic-backup
```
- As a convenience, a shortcut for the above commands are `$ make activate-launchagent`.
+ As a convenience, a shortcut for the above commands are `$ make activate-launchagent-backup`.
1. Watch the first backup progress from the log files:
```console
$ tail -f ~/Library/Logs/restic/backup*
@@ -155,7 +155,17 @@ Many Linux distributions nowadays use [Systemd](https://en.wikipedia.org/wiki/Sy
$ restic snapshots
```
1. (recommended) Enable the check job that verifies that the backups for the profile are all intact.
- TODO #81
+ * Homebrew install:
+ ```console
+ $ brew services start restic-automatic-backup-scheduler-check
+ ```
+ * `make` install:
+ ```console
+ $ launchctl bootstrap gui/$UID ~/Library/LaunchAgents/com.github.erikw.restic-check.plist
+ $ launchctl enable gui/$UID/com.github.erikw.restic-check
+ $ launchctl kickstart -p gui/$UID/com.github.erikw.restic-check
+ ```
+ As a convenience, a shortcut for the above commands are `$ make activate-launchagent-check`.
1. Consider more [optional features](#optional-features).
### Homebrew Setup Notes
@@ -252,7 +262,7 @@ Any system that has a cron-like system can easily setup restic backups as well.
**TL;DR setup**
-1. [Create](#1-create-backblaze-b2-account-bucket-and-keys) B2 bucket + credentials
+1. [Create](#1-create-backblaze-b2-account-bucket-and-keys) B2 bucket + credentials
1. Install scripts, configs systemd units/timers:
```console
$ sudo make install-cron
@@ -297,7 +307,7 @@ and you should now see that all files have been changed like e.g.
+export RESTIC_PASSWORD_FILE="/etc/restic/pw.txt"
```
-Why? The OS specific TL;DR setups above all use the [Makefile](Makefile) or a package manager to install these files. The placeholder string `$INSTALL_PREFIX` is in the source files for portability reasons, so that the Makefile can support all different operating systems. `make` users can set a different `$PREFIX` when installing like `PREFIX=/usr/local make install-systemd`.
+Why? The OS specific TL;DR setups above all use the [Makefile](Makefile) or a package manager to install these files. The placeholder string `$INSTALL_PREFIX` is in the source files for portability reasons, so that the Makefile can support all different operating systems. `make` users can set a different `$PREFIX` when installing like `PREFIX=/usr/local make install-systemd`.
In this detailed manual setup we will copy all files manually to `/etc`and `/bin`. Thus we need to remove the placeholder string `$INSTALL_PREFIX` in the source files as a first step.
@@ -317,7 +327,7 @@ For restic to be able to connect to your bucket, you want to in the B2 settings
#### 2. Configure B2 Credentials Locally
Put these files in `/etc/restic/`:
-* `_global.env.sh`: Fill this file out with your global settings including B2 keyID & applicationKey.
+* `_global.env.sh`: Fill this file out with your global settings including B2 keyID & applicationKey.
* `default.env.sh`: This is the default profile. Fill this out with bucket name, backup paths and retention policy. This file sources `_global.env.sh` and is thus self-contained and can be sourced in the shell when you want to issue some manual restic commands. For example:
```console
$ source /etc/restic/default.env.sh
@@ -421,7 +431,7 @@ To create a different backup and use you can do:
```console
# cp /etc/restic/default.env.sh /etc/restic/other.env.sh
# vim /etc/restic/default.other.sh # Set backup path, bucket etc.
-# source /etc/restic/default.other.sh
+# source /etc/restic/default.other.sh
# restic_backup.sh
```