cron and run-parts system #206
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#206
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
Can we create a cron job for the system and not for the root user. If I run a task with the root crontab, including using run-parts it goes well. But if I do exactly the same thing in /etc/cron.xxx with run-parts I have as a result:
/etc/cron.hourly/borgmatic:
Traceback (most recent call last):
File "/ root / bin / borgmatic", line 6, in
from borgmatic.commands.borgmatic import main
ModuleNotFoundError: No module named 'borgmatic'
run-parts: /etc/cron.hourly/borgmatic exited with return code 1
Running run-parts in a terminal with root works:
run-parts /etc/cron.hourly/.
/etc/borgmatic/config.yaml: Running command for pre-backup hook
Starting a backup job.
/ mnt / save / TEST: Pruning archives
.....
In two words it works with the root user but not for the system ...
Other notes / implementation ideas
Environment
borgmatic version: [version here]
Version: 1.3.14
borgmatic installation method: [e.g., Debian package, Docker container, etc.]
pip3 as official guide
Borg version: [version here]
borgbackup-1.2.0-0.a4.1.mga7
Python version: [version here]
Use
python --version
Python 2.7.16
operating system and version: [OS here]
Mageia release 7 (Official) for x86_64
Thanks for filing the ticket! This might be a Python path issue. Try adding
PYTHONPATH=/root/.local/lib/python3.7/site-packages
or similar (your version of Python may vary) to your cron job. See this example for how to insert environment variables like that in your cron job command invocation: https://projects.torsion.org/witten/borgmatic/src/branch/master/sample/cron/borgmaticNote that Python 2.x is unsupported. So the version of Python that borgmatic is using (if you installed with pip3) can most likely be found by running:
python3 --version
.Let me know if that helps!
Thanks for the solution.
With run-parts and cron.daily etc. folders it is the same.
the PYTHONPATH variable can be added to a script in /etc/cron.daily (or other /etc/cron.xxx) in the same way. For example, for a default configuration:
PYTHONPATH=/root/.local/lib/python3.7/site-packages borgmatic --stats 2>&1
Glad that worked out for you!