TAR EXCLUDES
#############
Citation:
http://stackoverflow.com/questions/984204/shell-command-to-tar-directory-excluding-certain-files-folders
If I wanted to not zip it:
# tar -cvf /c/sysroot-bak1.tgz –exclude ‘/c/*’ /
This would make a 500 mb file as tar appends files end to end without compression without the compression arguments (-z or -j and a couple others)
If I wanted to zip it
# tar -zcvf /c/sysroot-bak1.tgz –exclude ‘/c/*’ /
This would create a 100mb file as 500mb would compress down to that
OTHER OPTIONS:
#############
$ tar –exclude=’file1′ –exclude=’patter*’ –exclude=’file2′
Possible options to exclude files/directories from backup using tar:
*Exclude files using multiple patterns
tar -czf backup.tar.gz –exclude=PATTERN1 –exclude=PATTERN2 … /path/to/backup
*Exclude files using an exclude file filled with a list of patterns
tar -czf backup.tar.gz -X /path/to/exclude.txt /path/to/backup
*Exclude files using tags by placing a tag file in any directory that should be skipped
tar -czf backup.tar.gz –exclude-tag-all=exclude.tag /path/to/backup
* archive a given directory, but exclude various files & directories
* specified by their full file paths
find “$(pwd -P)” -type d \( -path ‘/path/to/dir1’ -or -path ‘/path/to/dir2’ \) -prune \
   -or -not \( -path ‘/path/to/file1’ -or -path ‘/path/to/file2’ \) -print0 |
   gnutar –null –no-recursion -czf archive.tar.gz –files-from –
   #bsdtar –null -n -czf archive.tar.gz -T –
*You can exclude directories with –exclude for tar. If you want to archive everything except /usr you can use
tar -zcvf /all.tgz / –exclude=/usr
*In your case perhaps something like
tar -zcvf archive.tgz arc_dir –exclude=dir/ignore_this_dir
RSYNC EXCLUDES:
###############
With an exclude file. In this file put all of the directories you want to exclude. For example I want to tar everthing from /cygdrive/d/* where star meaning all of the files and subdirectories but I would like to skip the following folders Because those contain alot of files that I just dont need backed up:
/cygdrive/d/0Programs/
/cygdrive/d/Downloads/
/cygdrive/d/Videos/
/cygdrive/d/cygwin/
/cygdrive/d/$RECYCLE.BIN/
/cygdrive/dSystem Volume Information/
First make a file called exclude1 that has the following content:
0Programs/
Downloads/
Videos/
cygwin/
$RECYCLE.BIN/
System Volume Information/
Then the command to run to exclude those:
rsync -ahv –human-readable –stats –progress –delete –log-file=”/path/to/log/file.txt” –exclude-from=”/full/path/to/exclude” “/cygdrive/d/” “/destination/”
Note the –delete is optional thats not necessary for the exclude to work also the /destination folder will not have a /destination/d/* more like /destination/* with * being the stuff inside the sources /cygdrive/d/*
Note how the source and destination end in a /, syntax is important. It comes with practice knowing what result you will have.

Leave a Reply

Your email address will not be published. Required fields are marked *