borgmatic-collective / docker-borgmatic

Borgmatic in Docker
GNU General Public License v3.0
313 stars 88 forks source link

Crontab.txt does not run borgmatic on schedule #295

Closed televisi closed 5 months ago

televisi commented 5 months ago

Hi,

This might not likely an issue, but someone might be able to confirm this for me. As part of the testing, I wanted to have borgmatic to run every 3 minutes followed with logrotate command every 5 minutes.

On \etc\borgmatic.d\crontab.txt file, I have the following

*/3 1 * * * PATH=$PATH:/usr/local/bin /usr/local/bin/borgmatic --stats -v 0 --log-file /etc/borgmatic.d/log/borgmatic.log --log-file-verbosity 1 2>&1
#run logrotate to borgmatic log file every 5 minute
*/5 * * * * bash -c 'logrotate /etc/borgmatic.d/logrotate.conf'

When I checked docker log, it only ran the logrotate every 5 minutes, but does not run the borgmatic; did I miss anything here?

INFO[2024-01-30T06:57:42+11:00] read crontab: /etc/borgmatic.d/crontab.txt   
INFO[2024-01-30T06:57:42+11:00] crontab is valid                             
The variable SUPERCRONIC_EXTRA_FLAGS is empty, starting normally
INFO[2024-01-30T06:57:42+11:00] read crontab: /etc/borgmatic.d/crontab.txt   
INFO[2024-01-30T07:00:00+11:00] starting                                      iteration=0 job.command="bash -c 'logrotate /etc/borgmatic.d/logrotate.conf'" job.position=1 job.schedule="*/5 * * * *"
INFO[2024-01-30T07:00:00+11:00] job succeeded                                 iteration=0 job.command="bash -c 'logrotate /etc/borgmatic.d/logrotate.conf'" job.position=1 job.schedule="*/5 * * * *"
INFO[2024-01-30T07:05:00+11:00] starting                                      iteration=1 job.command="bash -c 'logrotate /etc/borgmatic.d/logrotate.conf'" job.position=1 job.schedule="*/5 * * * *"
INFO[2024-01-30T07:05:00+11:00] job succeeded                                 iteration=1 job.command="bash -c 'logrotate /etc/borgmatic.d/logrotate.conf'" job.position=1 job.schedule="*/5 * * * *"

Thanks

grantbevis commented 5 months ago

Doesn't this need to be */3 * * * * not */3 1 * * * that means it will run every 3 minutes at 01:00 and then not for the rest of the day.

televisi commented 5 months ago

Doesn't this need to be */3 * * * * not */3 1 * * * that means it will run every 3 minutes at 01:00 and then not for the rest of the day.

Oh my!! what a rookie mistake, totally missed that "1" after "*/3". Thanks for this!

For the consecutive run, it ran the script from the crontab.txt file; how about the initial one? (especially when I have ENV "RUN_ON_STARTUP = true")?

Thanks

grantbevis commented 5 months ago

I don't understand the question sorry? If you mean about initialising your backup repo you need to do that manually as per the borgmatic instructions

televisi commented 5 months ago

Sorry, I should have made it clearer.

So, currently I have the docker env => RUN_ON_STARTUP = true With that, when I restarted the docker instance, it will run the borg backup automatically. The question is, which parameters does it use?

The reason is, because on my crontab.txt, I use the following command, ideally to use the same parameter when docker is restarted too: borgmatic --stats -v 0 --log-file /etc/borgmatic.d/log/borgmatic.log --log-file-verbosity 1 2>&1

Thanks

grantbevis commented 5 months ago

It runs it like this: https://github.com/borgmatic-collective/docker-borgmatic/blob/42e312f0fba61e0fa328e7334c483c92e5f8b5de/entry.sh#L81