Snapshot lists excluded directories - is that right?

I have the following for my backup command

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

/usr/bin/restic -r $RESTIC_REPOSITORY -p $INPUTFILE backup /home --exclude=$EXCLUDES  <snip>

when I run snapshot I see the (hopefully) excluded directories listed

ID             Time           Host                   Tags          Paths
7dcb5f1f  2019-10-18 21:26:28                     /home
								    etc etc

I am surprised to see those directories listed…is that expected behaviour? Are they actually being excluded?

If you want to exclude multiple directories, you have to apply the --exclude flag n times for the amount of excludes you want to make.
If you want to exclude a list of folders you would have to specify it in a --exclude-file.

Here is the docs for exclusion:

--exclude Specified one or more times to exclude one or more items

So specifying it only once causes your backup to actually include all the other dirs that don’t have the --exclude in front of them.

If you want to check out how your command is actually interpreted, you can use the following command on your shell:
ruby -e 'puts ARGV.inspect' restic -vv [...]
and then you just put in your restic command instead.

1 Like

sigh…so I have been backing up what I thought I was excluding :stuck_out_tongue:

Thanks for the clarification, I have modified my script.

Do I now need to run a command on my backup or will those files be removed automatically on the next cron run?

No they won’t be removed for snapshots done in the past. If you want to modify the contents snapshots done previously for example to remove a specific file or folder and its content you would have to re-write the snapshot.
Meaning you have to dump the snapshot to disk, and re-backup the folder with the files and or folders that you want to have excluded.
There is currently no supported way to alter an already made snapshot.
Here is the GitHub issue for tracking this lack of functionality:

Thanks for the information, they will be removed eventually based on the retention policy though, right?

No, not by default. Restic’s default behaviour is to forget snapshots by grouping them based on hostname and path (see restic forget --help). In your case the paths differ, which makes restic think those are 2 different sets of data.

What @764287 said is true. The way to resolve this issue is to use the --group-by option of the forget command.

--group-by host is probably what you want. You can also assign tags to snapshots then group by tags.