How to exclued a specific path in backup

Hi,

I’m trying to exclude c:\TOBK\PICS subfolder. But it seems there is a pattern matching. How can I specify to start matching from beginning o path? IT seems I have to match against the absolute path, i.e I have to match against c:\TOBK\PICS, but I cannot do it against the relative path after c:\TOBK). IS that right? Any way of making it work? Would the future –strip-prefix fix it?

c:\TOBK>cd c:\TOBK & restic -r d:\BKRETIC\REPO6 backup . --exclude “/PICS”
enter password for repository:
repository b0745d64 opened (version 2, compression level auto)
found 7 old cache directories in C:\Users\jalcaide\AppData\Local\restic, run restic cache --cleanup to remove them
using parent snapshot 45293376
[0:00] 100.00% 4 / 4 index files loaded

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

processed 6 files, 91.313 MiB in 0:02
snapshot 44c9fb9f saved

c:\TOBK> restic -r d:\BKRETIC\REPO6 ls latest
enter password for repository:
repository b0745d64 opened (version 2, compression level auto)
found 7 old cache directories in C:\Users\jalcaide\AppData\Local\restic, run restic cache --cleanup to remove them
[0:00] 100.00% 4 / 4 index files loaded
snapshot 44c9fb9f of [c:\TOBK] at 2026-01-11 01:22:25.5873046 +0100 CET by CISCO\jalcaide@CSCO-W-PW0JCGJ7 filtered by :
/20240908_011833.mp4
/PICS
/PICS/20240908_021559.jpg
/SUBFOLDER
/SUBFOLDER/x1.txt
/c
/c/TOBK
/c/TOBK/PICS
/c/TOBK/PICS/not_a_pic.txt
/x1.txt
/x2.txt

c:\TOBK>cd c:\TOBK & restic -r d:\BKRETIC\REPO6 backup . --exclude “PICS”
enter password for repository:
repository b0745d64 opened (version 2, compression level auto)
found 7 old cache directories in C:\Users\jalcaide\AppData\Local\restic, run restic cache --cleanup to remove them
using parent snapshot 44c9fb9f
[0:00] 100.00% 4 / 4 index files loaded

Files: 0 new, 0 changed, 4 unmodified
Dirs: 0 new, 2 changed, 1 unmodified
Added to the repository: 0 B (0 B stored)

processed 4 files, 84.843 MiB in 0:02
snapshot 1d7b4bf2 saved

c:\TOBK> restic -r d:\BKRETIC\REPO6 ls latest
enter password for repository:
repository b0745d64 opened (version 2, compression level auto)
found 7 old cache directories in C:\Users\jalcaide\AppData\Local\restic, run restic cache --cleanup to remove them
[0:00] 100.00% 4 / 4 index files loaded
snapshot 1d7b4bf2 of [c:\TOBK] at 2026-01-11 01:22:45.318445 +0100 CET by CISCO\jalcaide@CSCO-W-PW0JCGJ7 filtered by :
/20240908_011833.mp4
/SUBFOLDER
/SUBFOLDER/x1.txt
/c
/c/TOBK
/x1.txt
/x2.txt

c:\TOBK> restic -r d:\BKRETIC\REPO6 ls latest
enter password for repository:
repository b0745d64 opened (version 2, compression level auto)
found 7 old cache directories in C:\Users\jalcaide\AppData\Local\restic, run restic cache --cleanup to remove them
[0:00] 100.00% 5 / 5 index files loaded
snapshot 41c7a1eb of [c:\TOBK] at 2026-01-11 01:37:37.6936906 +0100 CET by CISCO\jalcaide@CSCO-W-PW0JCGJ7 filtered by :
/20240908_011833.mp4
/SUBFOLDER
/SUBFOLDER/x1.txt
/c
/c/TOBK
/c/TOBK/PICS
/c/TOBK/PICS/not_a_pic.txt
/x1.txt
/x2.txt

c:\TOBK>cd c:\TOBK & restic -r d:\BKRETIC\REPO6 backup . --exclude “\PICS”
enter password for repository:
repository b0745d64 opened (version 2, compression level auto)
found 7 old cache directories in C:\Users\jalcaide\AppData\Local\restic, run restic cache --cleanup to remove them
using parent snapshot 41c7a1eb
[0:00] 100.00% 5 / 5 index files loaded

Files: 1 new, 0 changed, 5 unmodified
Dirs: 1 new, 0 changed, 4 unmodified
Added to the repository: 0 B (0 B stored)

processed 6 files, 91.313 MiB in 0:02
snapshot 49fcfcb8 saved

c:\TOBK> restic -r d:\BKRETIC\REPO6 ls latest
enter password for repository:
repository b0745d64 opened (version 2, compression level auto)
found 7 old cache directories in C:\Users\jalcaide\AppData\Local\restic, run restic cache --cleanup to remove them
[0:00] 100.00% 5 / 5 index files loaded
snapshot 49fcfcb8 of [c:\TOBK] at 2026-01-11 01:38:13.8128904 +0100 CET by CISCO\jalcaide@CSCO-W-PW0JCGJ7 filtered by :
/20240908_011833.mp4
/PICS
/PICS/20240908_021559.jpg
/SUBFOLDER
/SUBFOLDER/x1.txt
/c
/c/TOBK
/c/TOBK/PICS
/c/TOBK/PICS/not_a_pic.txt
/x1.txt
/x2.txt

c:\TOBK>

You are on windows. There \Pics makes sense in terminals, but not within restic, because restic converts internally c:/foo/bar to /c/foo/bar.

Both \ and \ works
\foo\bar does not work, it must start with ‘:’ like ':\foo\bar’ or ‘C:\foo\bar’ to match from root on windows (TODO update)

So for your use case you can do

(star colon star / PICS, in case something ruins my text)
–exclude “*:*\PICS”

Here are some examples that may be of use for you

Examples

Grab the hosts file from excluded folder

!C:\Windows
C:\Windows*
!C:\Windows\System32
C:\Windows\System32*
!C:\Windows\System32\drivers
C:\Windows\System32\drivers*
!C:\Windows\System32\drivers\etc
C:\Windows\System32\drivers\etc*
!C:\Windows\System32\drivers\etc\hosts

Cloud services - restic will finish with exit code 3 on files with read errors on unsynced files (tested when using VSS-snapshot for OneDrive files)

Users*\Dropbox
Users*\OneDrive
AppData\Local\Google\Drive
Google Drive.tmp.drivedownload
*:\OneDriveTemp

THanks for the reply.

I’m not sure if you unswered my main point.. that the match is done with the source file path. In my example ‘c:\TOBK\PICS’

Said that, I am not sure if all your solutions worked. I tried the following with success:

–iexclude “*:\TOBK\PICS”

--iexclude “*:*\TOBK\PICS”

–iexclude “c:\TOBK\PICS”

–iexclude “c:/TOBK/PICS”

But these ones did not work:

–iexclude “*:*\PICS”

–iexclude “/TOBK/PICS”

–iexclude “:/TOBK/PICS”

I am not sure what your example means and how I would use “!C:\Windows\System32\drivers\etc\hosts” as part of a exclude command

hello @resticint001
you want to exclude the c:\TOBK\PICS subfolder.

Then your own examples make perfect sense that they passed and failed. Let me leave some comments next to them:

I tried the following with success:
--iexclude “*:\TOBK\PICS” >>> * can match the drive c
--iexclude “*:*\TOBK\PICS” >>> same and second * can match nothing
--iexclude “c:\TOBK\PICS” >>> full path match
--iexclude “c:/TOBK/PICS” >>> you can use / or \ and i believe | as well

But these ones did not work:
--iexclude “*:*\PICS” >>> cannot match the first subfolder
--iexclude “/TOBK/PICS” >>> cannot match the drive
--iexclude “:/TOBK/PICS” >>> cannot match the drive

Since you mentioned in your opening post that you want to “match against the relative path after c:\TOBK” then I would suggest you use this pattern:
--iexclude "*:\**\PICS
and if you want to keep the subfolder but not its content then this one (reference):
--iexclude "*:\**\PICS\*
The caveat with the first one is that if you have a PICS file somewhere in e.g. D:\some\fol\ders\PICS it will also be excluded. Since a trailing slash is ignored it seems to me restic cannot differentiate between file or folder now. From the (previous reference) there is a link to a github issue #4399