Different behaviour for backups when done via CLI or cronjob

I try to automate my backups with a cronjob but I noticed different behaviour if the backup is done from the cronjob compared to the manual backup vi CLI.

The manual backup looks like this:

open repository
lock repository
load index files
using parent snapshot 3217438f
start scan on [/foo/bar/baz]
start backup on [/foo/bar/baz]
scan finished in 0.642s: 4937 files, 1.268 GiB

Files:           0 new,     0 changed,  4937 unmodified
Dirs:            0 new,     5 changed, 14961 unmodified
Data Blobs:      0 new
Tree Blobs:      5 new
Added to the repo: 4.040 KiB

processed 4937 files, 1.268 GiB in 0:01
snapshot c22f8fb8 saved

This works as expected.

But if the backup is done from the cronjob, the output is only

open repository
lock repository
load index files
using parent snapshot 3217438f
start scan on [/foo/bar/baz]
start backup on [/foo/bar/baz]
scan finished in 0.352s: 128 files, 30.433 MiB

If I check afterwards there is no new snapshot.

The backup runs on a machine where I have only limitied access. Nevertheless, cron and CLI user should have the same access rights.
Any pointers where I should start to investigate this issue?

Hi :wave:

Do you log both stdout and stderr? If there is no snapshot at the end, restic should fail with something printed to the screen.

Also could you send the exact command you run restic within the cron?

The exact command is like this:

restic -r ${BACKUP_REPO} --verbose backup ${BACKUP_SOURCE} --password-file ${RESTIC_PWD} >> ${LOGFILE}

Any idea how I could log stderr? The configuration of the cronjob is only possible via a web interface.

&>> ${LOGFILE} should append both stdout and stderr.

Big kudos for your help! Error tracked down:

Fatal: unable to save snapshot: fs.TempFile: open /tmp/restic-temp-pack-134863653: permission denied

Configuring a different tmp directory as described here then did the trick!