--cache-dir not working and where is log?

I have a cron job with the following:

EXCLUDES="/home/cpsimple /home/**/.trash /home/var /**/tmp /home/**/.cache /home/**/cache/ /home/**/error_log /home/backup/** /home/virtfs"

CACHELOCATION = "/foo/bar/cache/restic"

export B2_ACCOUNT_ID="<snip>"
export B2_ACCOUNT_KEY="<snip>"

#### Backup
/usr/bin/restic -r $RESTIC_REPOSITORY -p $INPUTFILE backup /home --exclude=$EXCLUDES -o b2.connections=10 --exclude-caches -v --cleanup-cache --cache-dir=$CACHELOCATION

however the cache continues to be written to /root/cache/restic - what is the problem with my script?

Also, where on earth is the log file?


Brackets need to be escaped or do you want the shell to evaluate the term (user)?

sorry, that was just some obfuscation of the actual directory…

Restic does not have a log file. It prints its output to stdout/stderr.

Have you tried without those whitespaces in the declaration?

Thanks - but that is pretty odd for a piece of software that does such an important job.

sigh…yes, that is likely the problem. Thanks. Will see what happens at next cron run.

It’s the shell - not restic…

Restics output is not made to be parseable as well as it’s not primarily made to be run as a daemon like apache or sshd would be - not meaning you shouldn’t or can’t run it as a daemon with systemd, but don’t expect the output that is generated to be like apache or sshd would.

What you can do is you can use the json output to get parseable output if this is needed and then redirect the output to a file and have logrotate handle the rest.

Restic is designed to run on many different OSes in a variety of configurations. For example, restic does not need to be run as root/Administrator.

Considering this, it would be infeasible to come up with a set of rules that provide centralized logging. Where should user instances log vs. root instances?

It’s much simpler to let the system operator configure this by redirecting output. Or, for example, if the script is run from cron then cron will email any output to the local user who runs restic from their crontab.

Thanks for the responses.

The answer for others looking for info about backups, a brief overview of results can be logged by adding > /foo/bar/restic.log to the backup command which produces exactly what I was after

# cat restic.log

Files:       48875 new, 101525 changed, 9441107 unmodified
Dirs:            0 new,   304 changed,     8 unmodified
Added to the repo: 24.187 GiB

processed 9591507 files, 1.251 TiB in 2:22:32
snapshot c4db9139 saved