Windows: Exclude Recycle Bin?

I am trying to use restic to back up my Windows 10 system.

I want to create an ‘exclude file’ for all the stuff I don’t want to back up.

First and foremost, I don’t want to backup the recycle bin. But I am having difficulties how to specify the match in my exclude file.

I am invoking restic like this: restic -r myrepo backup -v -v -v --exclude-file=myexcludefile.txt c:\

But no matter what I put in the exclude file, I can’t keep it from going through the recycle bin.

Can anyone give me some real life exclude file segments for backing up your Windows system which actually work?

Thanks - Steven

Have you tried .*\$RECYCLE\.BIN/.* and .*/RECYCLER/.*?

Source: https://superuser.com/questions/443890/what-files-file-types-and-folders-to-exclude-from-user-folder-backup/444277

Just tried it now, no joy.
It looks like the restic specification is different than the one in the link you referenced (Java Regular Expression).

Thanks - Steven

Hmm, what have you tried that doesn’t work?

I would think that these lines in a exclude file would work:

$Recycle.Bin
Recycler

I’ve been doing more experimenting.

I wanted to specify $RECYCLE.BIN at the root of the file system only.

In Linux this would be /$$RECYCLE.BIN (the double $ to escape it in restic) but that didn’t work for Windows.

What I found out I needed to do was specify this: C:\$$RECYCLE.BIN

I wouldn’t expect that since I already specified C:\ as the start of the tree to backup. I wanted something like this: \$$RECYCLE.BIN so that I could use it when I backup D:\ as well. But I think I can live with putting the C:\ in the path.

Thanks for all the comments!

2 Likes

Yep, you’ve run into a corner case with Windows drive letters. I could argue that restic works this way so that you can chose to exclude C:\$RECYCLE.BIN, but still backup D:\$RECYCLE.BIN when running restic backup c:\ d:\, but it’s rather accidental that it works this way :wink:

For the clarification: Where did you specify that pattern? I suspect in an exclude file, correct? restic handles $ slightly different when passed in as command-line arguments or from files, in the latter case environment variables are expanded so you need to escape the $.

Yep. As I indicated, it isn’t too much of a restriction. I just didn’t expect the need to have C:\ start each of my exclude lines where I want to anchor it to the root. But now that I know, I can deal with it.

Note that when I was doing my experimenting, I had to use a local “throw away” restic repository, since I didn’t want to corrupt/interfere with my regular repository. Gee, it’s almost like we need a “–dry-run” option for cases like this :wink:

You are correct.

Thanks - Steven

Also, maybe the documentation can be enhanced to mention the windows-only case where the C:\ is important.

Is anybody up for a Pull Request? :slight_smile: