/etc/backups/run.sh does not find borg /home/user/.guix-profile/bin/borg
- Anmelden oder Registrieren um Kommentare zu schreiben
I am trying to set up automated backups with borg[1], however, I have an issue: `/etc/backups/run.sh` invokes borg but can't find borg:
$ grep -n ^borg /etc/backups/run.sh
68:borg --version
73:borg create $BORG_OPTS \
84:borg create $BORG_OPTS \
$ journalctl -fu automatic-backup | grep borg
Apr 04 19:36:15 x220 run.sh[15968]: /etc/backups/run.sh: line 68: borg: command not found
I installed borg using guix; `$ guix install borg`.
$ type borg
borg is hashed (/home/user/.guix-profile/bin/borg)
I have no issue invoking borg from the cli.
$ borg --version
.borg-real 1.4.3
or `borg list` or `borg create`.
and I can see `/home/user/.guix-profile/bin/` on `PATH`:
$ echo $PATH
/home/user/.local/bin:/home/user/bin:/home/user/.guix-profile/bin:/home/user/.config/guix/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
What else can I check to figure out why `/etc/backups/run.sh` can't find borg?
[1] https://borgbackup.readthedocs.io/en/stable/deployment/automated-local.html
Is /etc/backups/run.sh not run by root?
It is run by root.
$ ls -l /etc/backups/run.sh
-rwxr-xr-x 1 root root 2820 Apr 4 19:36 /etc/backups/run.sh
I have setup automated backup with borg on aramo, on a headless machine that I use as file server (samba and sftp), to a remote machine also running aramo. Actually, I use borgmatic, from trisquel.
On the server to backup, borgmatic runs as as the user that owns the files to backup, while on the machine for backup, I create a user that has in ~/.ssh/authorized_keys a line
restrict,command="borg serve --restrict-to-path /path/on/backup/machine" ssg-ed25519 AAAAAA file-ownser@file-server
where AAAAAA is the whole public key of the server. This is to restrict ssh to using borg and only on a special path. file-owner is the owner of the files and file-server the file server name. This has no functional importance, it is a comment that helps remembering where the private key of AAAAAAA is (so that if I want to remove it later, I can find that line easily if I allowed other users to connect from other machines).
Borgmatic runs periodically using a systemd user timer, which is configued by files in ~/.config/systemd/user, I used instructions at https://daveparrish.net/posts/2020-02-18-Borg-backup-automatic.html
I have plans to document my setup but it is not ready yet. I had to do something special for the service to run even though there is no session of the user that owns the files to backup. In my recollection, to setup the timer and make them run, instead of making a shell of the user that owns the files to backup, I use a command
machinectl shell file-owner@.host"
where file-owner is to be replaced by the username, while .host is exactly as written here.
Thanks for sharing this, Avron. My next project (with Borg) is to back up my local machine on a remote server. I'll come back to your comment when I do so.

