Score:0

How to force tar to include certain directories when using --exclude option

ma flag

I need to backup a hierarchy. I need to keep the image as small and fast as possible. I use

tar -c --exclude="..."

with several --exclude=".." patterns to omit quite a few directory/file patterns, and that works fine.

However, the hierarchy has several .git sub-directories dotted around inside it and I do want to include anything below such directories encountered in the backup. There is a chance directories/files below .git might match the --exclude="..." patterns, and they would currently get excluded.

Is there any way to tell tar that anything below a .git is to be included, regardless of --exclude? Or how could I handle this requirement?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.