Path working

This commit is contained in:
Erik Westrup
2022-02-09 14:58:31 +01:00
parent c8ab0b4421
commit d38616d697
2 changed files with 22 additions and 11 deletions

View File

@@ -6,12 +6,22 @@
<dict>
<key>Label</key>
<string>com.github.erikw.restic-automatic-backup</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>source /usr/local/etc/restic/erikw.env.sh &amp;&amp; /usr/local/bin/restic_backup.sh</string>
<string>export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin &amp;&amp; source /usr/local/etc/restic/erikw.env.sh &amp;&amp; PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin /usr/local/bin/restic_backup.sh</string>
</array>
<!-- how use $HOME? -->
<key>StandardOutPath</key>
<string>/Users/erikw/Library/Logs/restic/restic_stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/erikw/Library/Logs/restic/restic_stderr.log</string>
<key>RunAtLoad</key>
<true/>
<!-- Will schedule backup every day at 19:00 -->
@@ -24,15 +34,5 @@
<integer>0</integer>
</dict>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin</string>
</dict>
<!-- how use $HOME? -->
<key>StandardOutPath</key>
<string>/Users/erikw/Library/Logs/restic/restic_stdout.txt</string>
<key>StandardErrorPath</key>
<string>/Users/erikw/Library/Logs/restic/restic_stderr.txt</string>
</dict>
</plist>

View File

@@ -268,10 +268,21 @@ 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 bootstrap gui/$UID ~/Library/LaunchAgents/com.github.erikw.restic-automatic-backup.plist
$ launchctl enable gui/$UID/com.github.erikw.restic-automatic-backup
$ launchctl kickstart -p gui/$UID/com.github.erikw.restic-automatic-backup
```
Debug with
```console
$ sudo launchctl debug gui/$UID/com.github.erikw.restic-automatic-backup --stdout --stderr
```
TODO how disable?
```
$ launchctl disable gui/$UID/com.github.erikw.restic-automatic-backup
$ launchctl bootout gui/$UID/com.github.erikw.restic-automatic-backup
```
## Setup Cron
If you want to run an all-classic cron job instead, do like this: