Fatal: Options -r and --repository-file are mutually exclusive, please specify only one

Hi,
I completed setup of restic, rclone and resticprofile.
Since 4 weeks the scheduled backups fail.

My investigation returns this finding:

❯ rclone lsd cloud.mydomain.de:Backup/restic/miab                                                                     
          -1 2024-11-20 00:01:09        -1 data                                                                               
          -1 2024-12-29 13:57:10        -1 index
          -1 2023-12-30 21:46:28        -1 keys                                                                               
          -1 2024-12-29 14:23:00        -1 locks                                                                              
          -1 2024-11-20 00:00:46        -1 snapshots

❯ restic -r rclone:cloud.mydomain.de:Backup/restic/miab snapshots                                                     
Fatal: Options -r and --repository-file are mutually exclusive, please specify only one

I’m using restic 0.17.3 compiled with go1.23.3 on linux/amd64.

Can you please advise how to fix this?

THX

There must be something in your setup that makes restic run with both -r and --repository-file, and you need to find what it is.

You can set -x in your shell to see what commands are being run. Or you could perhaps check which restic is running and see if it’s a wrapper script that you are running, that adds the --repository-file option itself?

The code throwing that error message in restic 0.17.3 looks like this:

	repo := opts.Repo
	if opts.RepositoryFile != "" {
		if repo != "" {
			return "", errors.Fatal("Options -r and --repository-file are mutually exclusive, please specify only one")
		}

Do not use both at the same time:)

My bet is on environment variable RESTIC_REPOSITORY_FILE set.

$ export RESTIC_REPOSITORY_FILE="bla bla bla"
$ restic -r rclone:RW01-ENC:rustic_kptsky_backup snapshots
Fatal: Options -r and --repository-file are mutually exclusive, please specify only one

Check it:

$ echo $RESTIC_REPOSITORY_FILE
bla bla bla

clear it:

$ unset RESTIC_REPOSITORY_FILE

or do not use -r flag.

Simply use one or another but not both at the same time.

2 Likes

You’re smarter than me :smiling_face_with_tear:

1 Like

Something very similar happened to me few weeks ago and it took me looong time (which does not look very smart in retrospect:)) to find the reason. Only why now “I know”

1 Like

Indeed I had variables set in ~/.bashrc:

# Restic variables
export RESTIC_REPOSITORY_FILE=/home/thomas/.config/rclone/repo
export RESTIC_PASSWORD_FILE=/home/thomas/.config/rclone/pw

After removing these variables restic works as expected.

1 Like