I need to transfer a lot of web directories to another machine. The directory structure looks like this:
/var/www/
site1/
cgi-bin/ ...
logs/ ...
index.html
images/ ...
...
site2/
cgi-bin/
logs/
...
size3/
...
To pack the files I'd like to use tar
. I need to pack all files, except all "cgi-bin" and all "logs" directories only in certain provided paths, not in any subdirectory!
These directories should be excluded from packing because they should not appear in the destination and they can be quite large. That slows down the transfer. So I do not want to include them and only delete them in the destination.
I tried several combinations of this:
cd /var/www
tar cfz ~/web.tgz site* --exclude-from excludes.list
excludes.list is a file that contains lines such as shown here: (the example shows different path styles, I used each of them consistently for the entire file, but no variant worked)
site1/cgi-bin
site1/logs
./site2/cgi-bin
/var/www/site2/logs
The "cgi-bin" directories may occur in other subdirectories (I list them all with a find
command), the "logs" directories that I want to exclude are all directly in each "sitex" directory. Other "logs" directories must be included.
I could only get to two results:
- No files were excluded at all
- All directories that partially matched an exclude pattern were excluded, including e.g. /var/www/site2/bla/site1/logs/. This is not acceptable as it's excluding too much.
Is there a way to make tar
exclude exactly the absolute paths provided and nothing else that partially looks like a provided exclude pattern?
excludes.list
file all contains relative or all absolute paths? – αғsнιη Dec 03 '20 at 20:36