How to Tar excluding few sub directories

Many of us would have perform tar of directories for cloning/file movement between the servers.  Many times we would have think to exclude some sub-directories which are not needed, so that tar will save some time.
Here you go handy commands to achieve your needs.
Let’s say if you want to tar /u10/groups folder and want to exclude few sub directories under groups.
Cd /u10
user@/u10 > tar -cpvzf /tmp/groups.tar.gz groups –exclude-from=excl
user@/u10 > cat excl
groups/group-2/instance-1/core.119006
groups/group-2/instance-1/core.71016
groups/group-2/instance-1/core.75416
groups/group-2/instance-1/trace
groups/group-2/instance-1/conf/opsdb.d
groups/group-2/instance-1/conf/opsdb.d_bkup
groups/group-2/instance-1/conf/opsdb.d_bkup1
  • June 30, 2019 | 18 views
  • Comments