Commands working on terminal are not working in borgmatic hooks #1157
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
Hello there, I am trying to run some commands before the backup starts, and I have used the same command which is perfectly working when running on the terminal, but when I start the Borgmatic.service file, I am getting an error with that specific command. This is the command
The command above makes sure to create a backup of the ERP I am running and then copies the backup files from the container to the host path. I have added the erp_backup path in one of the paths to be backed up. I tried creating a shell file containing the same command and put
sudo /etc/borgmatic/pre_back.shin place of the whole command. But still receiving the same issueSteps to reproduce
Add the following in config.yaml to execute before back up starts,
Actual behavior
I am getting an error
Expected behavior
Just work as it worked on terminal
Other notes / implementation ideas
No response
borgmatic version
2.0.6
borgmatic installation method
Official Fedora Repository
Borg version
1.4.1
Python version
3.13.7
Database version (if applicable)
No response
Operating system and version
Fedora Linux 42 (WSL) x86_64
A few thoughts on this:
--verbosity 2?podmanfrom running? If so, you can start by commenting them out and reloading the service to see if that fixes it. If it does, you know at least one of them is causing the problem.Hello @witten thanks again,
Nothing else, journalctl -xeu borgmatic.service is not outputting anything.
I have used the default borgmatic.service and I didn't change anything, but it seems using that
# ExecStart=systemd-inhibit --who="borgmatic" --what="sleep:shutdown" --why="Prevent interrupting scheduled backup" /usr/bin/borgmatic --verbosity -2 --syslog-verbosity 1I haven't specified username and group on borgmatic.service, I am using the default file
I was checking with Gemeni, and it suggested that using -ti on the podman exec command might cause a problem, as it requires an interactive shell.
It shows the error when I tried "borgmatic create --list --stat" on terminal
Try changing
--syslog-verbosityto2. That should give you some more verbose output, viewable withjournalctl.That's a separate issue, but still possibly valid. You could try dropping the
-tiin thepodman execcommand.What I was talking about is all of the security options in the default borgmatic system service file. Everything fromLockPersonality=truethroughCapabilityBoundingSet=.... You could try commenting those out and runningsystemctl daemon-reloadto pick up the changes.However, reading on, it sounds like the problem still occurs when you run borgmatic manually, so that probably indicates that the problem isn't something introduced by the systemd service file.
Okay, in that case I'd recommend:
-tifrom thepodman execcommand.--verbosity 2to yourborgmatic createcommand to see if that gives a more useful error.As you suggested, I am running
sudo borgmatic create --list --stat --verbosity -2from the terminal before starting the systemd service, and there is no output when I run the above command.I removed -ti from podman exec, edited the .sh file, but as I said, there is no output trying from the terminal.
I added --verbosity 2 while running the borgmaic create, and I have created logfile.txt, now after removing -ti I get this in logs "Error: no container with name or ID "liyuerp_backend_1" found: no such container" which indicates the process is running as root, I guess, since I am running rootless podman. Since I am running Borgmatic as root, is that maybe an issue?
Ok After checking on AI, it seems working, now I am dealing with ssh but that's another problem, as I said the problem with the user who executing the podman exec command, since borgmatic is running with root and podman container is owned by non root user that was the reason...
Ah, glad to hear you've got it figured out now!