I am making a small script that compresses all the contents of the /var/www/html directory.
Inside I have a structure like this
- /var/www/html/prod/ vendor
- /var/www/html/tests/src/ vendor
That is, in all the directories I have a vendor directory
What I try with the script is to go through the entire main directory excluding all the directories that are called vendor, for this I do the following
DIA=`date +"%d%m%Y_%H%M"`
cd /tmp
rm -fr copia/
mkdir copia
cd copia
export GZIP=-9
tar -czvf $DIA-deploys.tar.gz --anchored --exclude=vendor * /root/deploys /var/www/html
But from what I see it includes the "vendor" directory.
You must exclude using a regular expression:
You can test the expression with
find
, because if it works in one, it will in the other: