How to exclude certain files from a tarball?

How to exclude certain files from a tarball?

The GNU version of the tar archiving utility has –exclude and -X options. So to exclude abc and xyz file you need to type the command as follows: $ tar -zcvf /tmp/mybackup.tar.gz –exclude=’abc’ –exclude=’xyz’ /home/me. If you have more than 2 files use -X option to specify multiple file names. It reads list of exclude file names from a text file.

What does it mean to exclude a file in tar?

‘ –exclude=pattern ’ Causes tar to ignore files that match the pattern. The ‘ –exclude=pattern ’ option prevents any file or member whose name matches the shell wildcard (pattern) from being operated on.

How does exclusion patterns work in GNU tar?

Patterns affect the directory and all its subdirectories. Before dumping a directory, tar checks if it contains file. If so, exclusion patterns are read from this file. The patterns affect only the directory itself. Same as ‘ –exclude-ignore ’, except that the patterns read affect both the directory where file resides and all its subdirectories.

Why does tar ignore files that match the pattern?

Causes tar to ignore files that match the pattern. The ‘ –exclude=pattern ’ option prevents any file or member whose name matches the shell wildcard (pattern) from being operated on.

Can you exclude certain directories in tar shell?

Backup doesn’t mean all the files and folders need to be backed up ! Sometimes we may have to exclude directories like template cache, log files, cache, temporarily created files, gallery directory etc., So in this article, we will see how to exclude certain directories and certain patterns even !

How to exclude Zyz and ABC files using tar?

How do I exclude zyz and abc file while using a tar command? The GNU version of the tar archiving utility has –exclude and -X options. So to exclude abc and xyz file you need to type the command as follows: $ tar -zcvf /tmp/mybackup.tar.gz –exclude=’abc’ –exclude=’xyz’ /home/me.

Are there trailing slashes in GNU tar 1.29?

THE TRAILING SLASHES MATTER: at least in GNU tar 1.29, it shouldn’t be any. In my case, for GNU tar 1.29 on Debian stretch, the command that worked was