Borg CRITICAL [Errno 2] No such file or directory: 'borg': 'borg' #412

Closed
opened 2021-04-21 20:38:48 +00:00 by naweap · 3 comments

Imported from https://github.com/borgbackup/borg and possibly related to borgmatic.

Have you checked borgbackup docs, FAQ, and open Github issues?

Yes

Is this a BUG / ISSUE report or a QUESTION?

ISSUE

System information. For client/server mode post info for both machines.

Your borg version (borg -V) :

borg 1.1.16

Operating system (distribution) and version :

Linux raspberrypi4 5.10.17-v7l+

How much data is handled by borg?

Around 300 GB

Full borg commandline that lead to the problem (leave away excludes and passwords) :

/home/borg/.local/bin/borgmatic -c /etc/borgmatic/gitea_primary.config.yaml

Describe the problem you're observing.

Hi guys, I'm running borg and it works well.

It's only been a few days since I'm facing an issue. I'm not sure if it's related to borg, borgmatic or something else but I will try to explain.

I'm using a systemd service in order to run backups. The service file looks like the following :

[Unit]
Description=Borgmatic gitea primary
After=network.target
Wants=network-online.target
[Service]
Restart=no
Type=exec
ExecStart=/home/borg/.local/bin/borgmatic -c /etc/borgmatic/gitea_primary.config.yaml
User=borg
Group=borg
Environment='BORG_PASSCOMMAND=cat /home/borg/.borg-passphrase'
[Install]

As you can see I'm running the ExecStart command with a user named borg. When I run this service, I get the following error :

avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL /etc/borgmatic/gitea_primary.config.yaml: Error running configuration file
avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL
avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL summary:
avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL /etc/borgmatic/gitea_primary.config.yaml: Error running configuration file
avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL /mnt/gitea_primary/backups: Error running actions for repository
avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL [Errno 2] No such file or directory: 'borg': 'borg'
avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL
avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL Need some help? https://torsion.org/borgmatic/#issues

But when I'm logging manually with the borg user and running the command placed in the ExecStart, the backup runs successfully.

I don't know where this error could come from. I found similar issues already but no one is related with mine.

Does someone has an idea of where the issue could come from ?

Thanks in advance.

Imported from https://github.com/borgbackup/borg and possibly related to borgmatic. <!-- Thank you for reporting an issue. *IMPORTANT* - *before* creating a new issue please look around: - Borgbackup documentation: http://borgbackup.readthedocs.io/en/stable/index.html - FAQ: https://borgbackup.readthedocs.io/en/stable/faq.html and - open issues in Github tracker: https://github.com/borgbackup/borg/issues If you cannot find a similar problem, then create a new issue. Please fill in as much of the template as possible. --> ## Have you checked borgbackup docs, FAQ, and open Github issues? Yes ## Is this a BUG / ISSUE report or a QUESTION? ISSUE ## System information. For client/server mode post info for both machines. #### Your borg version (borg -V) : borg 1.1.16 #### Operating system (distribution) and version : Linux raspberrypi4 5.10.17-v7l+ #### How much data is handled by borg? Around 300 GB #### Full borg commandline that lead to the problem (leave away excludes and passwords) : /home/borg/.local/bin/borgmatic -c /etc/borgmatic/gitea_primary.config.yaml ## Describe the problem you're observing. Hi guys, I'm running borg and it works well. It's only been a few days since I'm facing an issue. I'm not sure if it's related to borg, borgmatic or something else but I will try to explain. I'm using a systemd service in order to run backups. The service file looks like the following : ``` [Unit] Description=Borgmatic gitea primary After=network.target Wants=network-online.target [Service] Restart=no Type=exec ExecStart=/home/borg/.local/bin/borgmatic -c /etc/borgmatic/gitea_primary.config.yaml User=borg Group=borg Environment='BORG_PASSCOMMAND=cat /home/borg/.borg-passphrase' [Install] ``` As you can see I'm running the ExecStart command with a user named borg. When I run this service, I get the following error : ``` avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL /etc/borgmatic/gitea_primary.config.yaml: Error running configuration file avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL summary: avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL /etc/borgmatic/gitea_primary.config.yaml: Error running configuration file avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL /mnt/gitea_primary/backups: Error running actions for repository avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL [Errno 2] No such file or directory: 'borg': 'borg' avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL avr 21 01:00:14 raspberrypi4 borgmatic[29905]: CRITICAL Need some help? https://torsion.org/borgmatic/#issues ``` But when I'm logging manually with the borg user and running the command placed in the ExecStart, the backup runs successfully. I don't know where this error could come from. I found similar issues already but no one is related with mine. Does someone has an idea of where the issue could come from ? Thanks in advance. <!-- If this complaint relates to borg performance, please include CRUD benchmark results and any steps you took to troubleshoot. How to run benchmark: http://borgbackup.readthedocs.io/en/stable/usage/benchmark.html *IMPORTANT* - Please mark logs and text output from terminal commands or else Github will not display them correctly. An example is provided below. Example: ``` this is an example how log text should be marked (wrap it with ```) ``` -->
Owner

My guess is that even though you're running as the borg user in both cases, the user's environment is not being used when running in the systemd service, and therefore borgmatic can't find the borg executable on the system path.

One way to fix that would be to make use of systemd's Environment option, which would allow you to set the system path to contain the directory where borg is located. If you don't know where borg is located, you can just type which borg as the borg user.

Hope that helps! Let me know either way.

My guess is that even though you're running as the `borg` user in both cases, the user's environment is not being used when running in the systemd service, and therefore borgmatic can't find the `borg` executable on the system path. One way to fix that would be to make use of systemd's [`Environment` option](https://manpages.debian.org/buster/systemd/systemd.exec.5.en.html#ENVIRONMENT), which would allow you to [set the system path](https://stackoverflow.com/questions/35439123/systemd-environment-directive-to-set-path/37341810#37341810) to contain the directory where `borg` is located. If you don't know where `borg` is located, you can just type `which borg` as the `borg` user. Hope that helps! Let me know either way.
witten added the
question / support
label 2021-04-22 04:00:53 +00:00
Author

I set the system path using the environment option as you said and it worked.

My service file looks like the following now :

[Unit]
Description=Borgmatic gitea primary
After=network.target
Wants=network-online.target
[Service]
Restart=no
Type=exec
ExecStart=/home/borg/.local/bin/borgmatic -c /etc/borgmatic/gitea_primary.config.yaml
User=borg
Group=borg
Environment='BORG_PASSCOMMAND=cat /home/borg/.borg-passphrase'
Environment='PATH=$PATH:/home/borg/.local/bin:/usr/bin/'
[Install]

Thanks for your answer

I set the system path using the environment option as you said and it worked. My service file looks like the following now : ``` [Unit] Description=Borgmatic gitea primary After=network.target Wants=network-online.target [Service] Restart=no Type=exec ExecStart=/home/borg/.local/bin/borgmatic -c /etc/borgmatic/gitea_primary.config.yaml User=borg Group=borg Environment='BORG_PASSCOMMAND=cat /home/borg/.borg-passphrase' Environment='PATH=$PATH:/home/borg/.local/bin:/usr/bin/' [Install] ``` Thanks for your answer
Owner

Great, I'm glad to hear that did it!

Great, I'm glad to hear that did it!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#412
No description provided.