A client uploads files to a development server. When it's time to upload the project to a production server, those files are no longer needed, and we'd like to exclude them from the tar file we'll eventually push to production. However, we still want to keep the directory in tact, it's only the files that are not needed
Using Ubuntu 16 and tar 1.28, we've tried:
tar -vczf archive.tar.gz . --exclude=wp-content/uploads/wpallimport/files/*
tar: Cowardly refusing to create an empty archive
We've also tried enclosing exclude= parameter in single and double quotations, no luck.
tar -vczf archive.tar.gz . --exclude='wp-content/uploads/wpallimport/files/*'
tar: Cowardly refusing to create an empty archive
The official website shows –exclude without equals sign
tar -vczf file.tar.gz --exclude 'directory/*' .
and gives the same error.
How is this done?
Best Answer
The usual gotcha with
tar
's--exclude
option is that it is relative to the directory argument e.g. giventhen
fails to exclude the contents of
subsubdir
(it's trying to excludedir/dir/subdir/subsubdir/*
, which doesn't match anything); what you want isAFAIK the order doesn't matter except that the output file must immediately follow the
f
option.