Skip to content

Exit code 0 instead of 3 when directory given by --files-from is not readable #4467

@bodemann

Description

@bodemann

Output of restic version

restic 0.16.0 compiled with go1.20.6 on linux/amd64

I used 0.14 on the same infrastructure before which had the same problem.

How did you run restic exactly?

The command was used to reproduce the problem:

/usr/bin/restic -r rclone:storagebox:Backups/BigNas -p /home/jb/Documents/restic-storagebox-bignas-pwd.txt backup --files-from /home/jb/Documents/test-dir-list.txt

What backend/server/service did you use to store the repository?

rclone

Expected behavior

echo $? returns 3

Reason:

The text file test-dir-list.txt (parameter for --files-from listing the dirs to backup) contains the following line:

/mnt/Daten/Backups/Gogs-not-there

This dir does not exist. This is done to simulate a non reachable NFS share.

https://restic.readthedocs.io/en/latest/040_backup.html#exit-status-codes states:

Restic returns one of the following exit status codes after the backup command is run:

0 when the backup was successful (snapshot with all source files created)
1 when there was a fatal error (no snapshot created)
3 when some source files could not be read (incomplete snapshot with remaining files created)

Program output:

repository e8bb90c9 opened (version 2, compression level auto)
using parent snapshot 58fa48ca

Files: 0 new, 0 changed, 2270 unmodified
Dirs: 0 new, 0 changed, 16 unmodified
Added to the repository: 0 B (0 B stored)

processed 2270 files, 711.119 MiB in 0:03
snapshot 6a5fa242 saved

Actual behavior:
echo $? returns 0

Expected behavior:
echo $? returns 3

I hope I did not understand anything wrong and waste your time with this bug report. If I am correct though this bug IMHO might be critical since it allows incomplete backups without notice.

The actual backup in my case is done by a golang progam I wrote. The important lines are:

cmd := exec.Command(program, repo, repoParam, pwd, pwdParam, command, files, filesParam, tls, cacert, cacertParam)
if err := cmd.Run(); err != nil {
return fmt.Sprintf("Error creating restic snapshot into repo:%s: %s\n", repoName, err.Error())
}

This did not catch a NFS share disconnect.

Steps to reproduce the behavior

Use restic with --files-from that contains a non reachable dir.

Do you have any idea what may have caused this?

No

Do you have an idea how to solve the issue?

No

Did restic help you today? Did it make you happy in any way?

Yes, it helps me every day. I am glad restic exists and I am impressed with the work the restic team is doing over such a long period of time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions