Apparently successful backup with non-zero exit code

Hi folks.
I’m using restic 0.12.1 compiled with go1.16.6 on mint 20.3.

My daily restic backup script warned me it has ended with non-zero code. Details of restic output are given below:

########################
Wed 09 Mar 2022 07:05:07 AM -03
Restic Backup
using parent snapshot 5880921d

Files: 28 new, 0 changed, 31238 unmodified
Dirs: 4 new, 24 changed, 2667 unmodified
Added to the repo: 96.662 MiB

processed 31266 files, 19.897 GiB in 0:32
snapshot 8c98f57f saved
Exit Code: 3
########################

Aside the “Exit Code: 3”, no other warning message.

After 15 minutes my script retried the last operation and everything seemed to finished alright:

########################
Wed 09 Mar 2022 07:20:01 AM -03
Restic Backup
using parent snapshot 8c98f57f

Files: 0 new, 0 changed, 31266 unmodified
Dirs: 0 new, 5 changed, 2690 unmodified
Added to the repo: 10.688 KiB

processed 31266 files, 19.897 GiB in 0:12
snapshot 8d387ba7 saved
Exit Code: 0
########################

Just runned restic-check (without --read-data) and no errors found.

Is there a way I could debug this further to understand what happened?

Thanks in advance and sorry if this is a basic question.

From restic help backup:

Exit status is 0 if the command was successful.
Exit status is 1 if there was a fatal error (no snapshot created).
Exit status is 3 if some source data could not be read (incomplete snapshot created).

Since you haven’t showed us what the actual restic command (all of it, including any redirections) looks like, and how/in what context you run it, it’s hard to say what caused it.

But presumably some files could not be read. That’s what the exit code means.

1 Like

@rawtaz , thanks for your reply.

The exact restic command was

restic -r rclone:ufop:restic backup \ /home/oliveira/Desktop \ /home/oliveira/Documents \ /home/oliveira/Pictures \ /home/oliveira/Work \ /home/oliveira/.local/bin \ /home/oliveira/.local/config \ --tag NB
Not sure if this is what you needed.

I was wondering if restic saves some log in my system where I could take a look… anyways, I have no idea why some files could not be read.

Well, thanks again.

p.s. – This ufop:restic is my Google Drive remote.

Afaik this can also happen if you have any transient folders, e.g. a temporary file is deleted while you’re getting the backup.

Indeed. This is absolutely reasonable.

restic does not store any log files. Judging from the output your log files could be missing stderr. Getting the exit code 3 without restic printing a corresponding error message is not possible.

You are right. I just noted the missing 2>&1 in my log file redirection. Thank you very much.

So the command you pasted earlier was not the full command you are actually running in the end?

Well, now I understand what you meant by full command. And the answer then is no. I’m sorry about that.

I had an anacrontab like this: 7 5 restic.daily /path/to/restic-script.sh >> /path/to/restic-dell.log and restic-script.sh has that command I pasted earlier. Now I have added the aforementioned 2>&1 in restic’s output redirection.

Again, my bad.

1 Like