tar exclude directory 1

tar exclude directory

# create a gzip archive of my-backup-folder
# but exclude all node_module directories
# flags:
#	--exclude = exclude files, given as a PATTERN
# 	-c = create a new archive
# 	-z = filter the archive through gzip
# 	-f = use archive file or device ARCHIVE
#
# IMPORTANT NOTE:
# the exclude flag needs to come first to work
tar --exclude "node_modules" -czf backup.tar.gz /my-backup-folder

Here is what the above code is Doing:
1. tar = create a new archive
2. –exclude = exclude files, given as a PATTERN
3. -c = create a new archive
4. -z = filter the archive through gzip
5. -f = use archive file or device ARCHIVE

Similar Posts