I try to automate backing up the home directory to BorgBase using a script and a systemd service and timer.
The script runs fine when manually launched from /var/home/username/.bin/remote_backup.sh but I get the borg: command not found error when starting the systemd service (full output below).
× remote_backup.service - Remote backup to BorgBase
Loaded: loaded (/var/home/username/.config/systemd/user/remote_backup.service; disabled; preset: disabled)
Drop-In: /usr/lib/systemd/user/service.d
└─10-timeout-abort.conf
Active: failed (Result: exit-code) since Sun 2024-10-13 12:39:59 BST; 2s ago
Duration: 15ms
Process: 84380 ExecStart=/home/username/.bin/remote_backup.sh (code=exited, status=127)
Main PID: 84380 (code=exited, status=127)
CPU: 15ms
Oct 13 12:39:59 user-laptop systemd[2332]: Started remote_backup.service - Remote backup to BorgBase.
Oct 13 12:39:59 user-laptop remote_backup.sh[84380]: Sun 13 Oct 12:39:59 BST 2024 Starting backup
Oct 13 12:39:59 user-laptop remote_backup.sh[84384]: /home/username/.bin/remote_backup.sh: line 18: borg: command not found
Oct 13 12:39:59 user-laptop remote_backup.sh[84380]: Sun 13 Oct 12:39:59 BST 2024 Pruning repository
Oct 13 12:39:59 user-laptop remote_backup.sh[84388]: /home/username/.bin/remote_backup.sh: line 52: borg: command not found
Oct 13 12:39:59 user-laptop remote_backup.sh[84380]: Sun 13 Oct 12:39:59 BST 2024 Compacting repository
Oct 13 12:39:59 user-laptop remote_backup.sh[84380]: Sun 13 Oct 12:39:59 BST 2024 Backup, Prune, and/or Compact finished with errors
Oct 13 12:39:59 user-laptop systemd[2332]: remote_backup.service: Main process exited, code=exited, status=127/n/a
Oct 13 12:39:59 user-laptop systemd[2332]: remote_backup.service: Failed with result 'exit-code'.
And here is the remote_backup.service:
[Unit]
Description=Remote backup to BorgBase
[Service]
Type=simple
ExecStart=/home/username/.bin/remote_backup.sh
[Install]
WantedBy=default.target