从 tar 中排除目录

从 tar 中排除目录

我尝试压缩我的 WordPress 目录/srv/www/vhost/wp-intranet

但我需要排除该目录 /srv/www/vhost/wp-intranet/wp-content/uploads/

首先,我将目录更改为,/srv/www/vhost/然后尝试使用这些命令中的每一个,但都未能排除该目录:

tar --exclude="/srv/www/vhost/wp-intranet/wp-content/uploads/" -zcvf wp-intranet.tar.gz wp-intranet/

tar --exclude="./wp-intranet/wp-content/uploads/*" -zcvf wp-intranet.tar.gz wp-intranet/

tar --exclude="./wp-content/uploads/*" -zcvf wp-intranet.tar.gz wp-intranet/

答案1

弄清楚了。我必须执行这个:

tar --exclude="wp-intranet/wp-content/uploads" -zcvf wp-intranet.tar.gz wp-intranet/

相关内容