Software >> OS >> Unix >> How to use tar to backup with exclusion

1. Assume the following directory tree needs to be backed up /temp | -- dir1 -- dir2 -- dir3 2. Assume /temp/dir2 and /temp/dir3 is to be excluded Method 1 ======== # tar cvf /dev/st0 --exclude /temp/dir2 --exclude /temp/dir3 /temp/* Method 2 ======== # tar cvf /dev/st0 -X ./backup_excl.txt /temp/* where ./backup_excl.txt contains:- /temp/dir1 /temp/dir2 Method 3 ======== # tar cvfX /dev/st0 ./backup_excl.txt /temp/*