Tar -X not excluding

This has got to be something really silly on my part, but I can’t see it. I’m trying to back up my home directory to a usb drive with:

tar -X ~/.grsync/exclude.txt -cvpzf /run/media/dave/Backups/fedorabackup.tar.gz ~

The exclude file I’m specifying with the -X option is the same one I use with grsync (and I guess I’d better check that it’s working there). Inside that file (among other lines) is the line:

Downloads/

which, AFAIK, should mean that the entire Downloads folder in the folder where I’m executing the tar command will be entirely ignored (i’m running this from ~). Instead, I see it happily backing up the contents of Downloads (I’m being specific on Downloads only because the files are big enough that I can notice them being backed up).

I’ve tried variations within the exclude file like /Downloads/, ~/Downloads/ and it makes no difference. I’ve tried replacing the tildes in the tar command with /home/dave (my username) and it still does the same thing. What am I missing?

Apparently, rsync/gsync and tar don’t have the same structure to their exclude files (or I did something wrong there, too). “Downloads/” isn’t correct for tar. It needs to be “Downloads/*” (it needs that trailing asterisk).

2 Likes