`autorestic cron` does not work even when `cron` settings are defined in `global` section of the config
Describe the bug
Definition of the cron in global section of the config leads to autorestic cron being launched but doing nothing, as I see in log file.
Expected behavior
autorestic cron command should work and do something and there should be log records of command working,
Environment
- OS: Ubuntu
- Version: 24.04
- Autorestic version: 1.8.3
Additional context I create the following config:
version: 2
extras:
backup: &backup
exclude-file: []
forget: &forget
keep-last:
- 10
forgetoption: prune
complete_options: &complete_options
backup:
<<: *backup
global:
forget:
keep-last: 5
keep-daily: 4
keep-weekly: 1
keep-monthly: 12
keep-yearly: 7
locations:
home_user:
from: /home/user
to:
- somehost
options:
<<: *complete_options
shared_ssl:
from: /etc/ssl/shared
to:
- somehost
options:
<<: *complete_options
backends:
somehost:
type: rest
path: http://sub.example.tld:22002/
rest:
user: user
password: password
- and the following cron job (from sudo):
#Ansible: Autorestic backup
5 * * * * /home/user/backup-restic-node/autorestic/scripts/update-cron-debug.sh
PATH="/usr/local/bin:/usr/bin:/bin"
autorestic -c /home/user/backup-restic-node/autorestic/config/.autorestic.yaml --ci cron > /tmp/autorestic.log 2>&1
as you can see, it writes an output to /tmp/autorestic.log file, but after execution of the command only the following is written there:
$user: ~/ ❯ sudo cat /tmp/autorestic.log
Using config: /home/user/backup-restic-node/autorestic/config/.autorestic.yaml
Using env: /home/user/backup-restic-node/autorestic/config/.autorestic.env
Using lock: /home/user/backup-restic-node/autorestic/config/.autorestic.lock.yml
- and that's it. The actual backup procedure does not happen. What is going on?
I watched for this for 3 days and it did nothing. The manual backup works good.
You need to add a cron: ... option under each location: https://autorestic.vercel.app/location/cron
When you call autorestic cron, it checks all locations to see if they have a cron: ... in their config and if it's their time to run. It then stores the last time it last backed up a location through cron in the lock file to remember.
The idea is that you call autorestic cron in your OS' cron system very often. It runs the backup the first time, then most of the other times it does nothing and then when it's been long enough, it'll do the backup again.
Edit, I stumbled on your discussion thread and I gave a much more detailed explanation in there: https://github.com/cupcakearmy/autorestic/discussions/424#discussioncomment-13007342