How to exclude files?

I’m seriously bewildered. I’ve been working for almost an hour trying to follow instructions here - - about how to exclude files. Nothing works. Sample output:

tomc@ANB:~/programs/restic-backup$ ./restic -r /media/tomc/usbHD2-lv1/_restic-bkup/hiddensPlusRoot backup /home/tomc/ --exclude-file=restic-excludes-hiddensPlusRoot.txt
open repository
enter password for repository:  
repository 498a0239 opened successfully, password is correct
open restic-excludes-hiddensPlusRoot.txt: no such file or directory

The file DOES exist, and is sitting alongside the restic executable.

I decide to look up the exclude or exclude-file flag…and find it doesn’t exist! Huh? They are not in the listed commands or flags.

I’m running restic 0.9.4 compiled with go1.11.4 on linux/amd64

What am I misunderstanding?

Have you tried indicating the path of the file?


restic help only shows flags that are common to all commands. See restic help backup:

$ restic help backup

The "backup" command creates a new snapshot and saves the files and directories
given as the arguments.

  restic backup [flags] FILE/DIR [FILE/DIR] ...

  -e, --exclude pattern                  exclude a pattern (can be specified multiple times)
      --exclude-caches                   excludes cache directories that are marked with a CACHEDIR.TAG file
      --exclude-file file                read exclude patterns from a file (can be specified multiple times)
      --exclude-if-present stringArray   takes filename[:header], exclude contents of directories containing filename (except filename itself) if header of that file is as provided (can be specified multiple times)
      --files-from stringArray           read the files to backup from file (can be combined with file args/can be specified multiple times)
  -f, --force                            force re-reading the target files/directories (overrides the "parent" flag)
  -h, --help                             help for backup
  -H, --host hostname                    set the hostname for the snapshot manually. To prevent an expensive rescan use the "parent" flag
  -x, --one-file-system                  exclude other file systems
      --parent string                    use this parent snapshot (default: last snapshot in the repo that has the same target files/directories)
      --stdin                            read backup from stdin
      --stdin-filename string            file name to use when reading from stdin (default "stdin")
      --tag tag                          add a tag for the new snapshot (can be specified multiple times)
      --time string                      time of the backup (ex. '2012-11-01 22:08:41') (default: now)
      --with-atime                       store the atime for all files and directories

Global Flags:
      --cacert file               file to load root certificates from (default: use system certificates)
      --cache-dir string          set the cache directory. (default: use system default cache directory)
      --cleanup-cache             auto remove old cache directories
      --json                      set output mode to JSON for commands that support it
      --key-hint string           key ID of key to try decrypting first (default: $RESTIC_KEY_HINT)
      --limit-download int        limits downloads to a maximum rate in KiB/s. (default: unlimited)
      --limit-upload int          limits uploads to a maximum rate in KiB/s. (default: unlimited)
      --no-cache                  do not use a local cache
      --no-lock                   do not lock the repo, this allows some operations on read-only repos
  -o, --option key=value          set extended option (key=value, can be specified multiple times)
      --password-command string   specify a shell command to obtain a password (default: $RESTIC_PASSWORD_COMMAND)
  -p, --password-file string      read the repository password from a file (default: $RESTIC_PASSWORD_FILE)
  -q, --quiet                     do not output comprehensive progress report
  -r, --repo string               repository to backup to or restore from (default: $RESTIC_REPOSITORY)
      --tls-client-cert string    path to a file containing PEM encoded TLS client certificate and private key
  -v, --verbose n                 be verbose (specify --verbose multiple times or level n)

Well, the documentation doesn’t use quotes around the file name, and I had no expectation of needing to unless there was a space in the name. There isn’t.

But I discovered that there WAS a space at the END of the file name. I’ve never seen that before. It was "…txt ". So, the file name I gave truly was NOT a match. Removing the space fixed the problem. The backup is running fine now.

Live and learn…eventually. Thanks for the quick response, and for getting me to look again at the name.


Very helpful. Thanks.

1 Like

Question: Is this a convention that is understood by those in the Linux world who (unlike some of us!) live on the command line?

Seems to me it would be helpful to explicitly state that a list of flags is “only those common to all commands”. That would have saved me serious time today. A tiny point, unless one trips over it.

1 Like

Most command-line tools I’ve used (I live in the CLI as well) don’t have subcommands, so your question is a bit flawed in that sense. It would be a bit like expecting every command line tool on the whole system to take exactly the same set of flags, even though the commands serve different purposes.

Likewise, it would make no sense for restic check to accept exactly the same flags as restic backup. But there is a common set of flags (like -r) that make sense for every command to take.

Note at the end of restic help there is this line:

Use "restic [command] --help" for more information about a command.

(This is a synonym for restic help [command].)


I see your point. Of course, I now have some hindsight to employ. Often helps!

Thanks for your response.

Restic appears to be working perfectly for me now. I find it pretty amazing.


A post was split to a new topic: Exclude file format