linux - 创建 .tar.gz 文件时排除目录

我有一个 /public_html/ 文件夹,在该文件夹中有一个 /tmp/ 文件夹,其中包含大约 70gb 的我并不真正需要的文件。

现在我正在尝试创建 /public_html/.tar.gz 不包括 /tmp/

这是我运行的命令:

tar -pczf MyBackup.tar.gz /home/user/public_html/ --exclude "/home/user/public_html/tmp/" 

tar 仍在创建中,通过执行 ls -sh 我可以看到 MyBackup.tar.gz 已经有大约 30gb,我确定没有 /tmp//public_html/ 文件不超过 1GB。

我做错了什么?

最佳答案

尝试删除要排除的目录路径末尾的最后一个/

tar -pczf MyBackup.tar.gz /home/user/public_html/ --exclude "/home/user/public_html/tmp" 

https://stackoverflow.com/questions/4290174/

相关文章:

python - 如何让 Flask 在端口 80 上运行?

python - 在 Python 2.6 中不推荐使用 BaseException.message

linux - 在 bash 中检查当前分区的可用磁盘空间

python - 将字符串转换为 Python 类对象?

python - 无法使用 Ctrl-C 终止 Python 脚本

linux - tar.gz 和 tgz 是一回事吗?

linux - 从 linux shell 脚本发送邮件

python - 无法安装 Python 包 [SSL : TLSV1_ALERT_PROTOCOL

python - 通过urllib和python下载图片

linux - ~/.ssh/config 文件中的 SSH 端口转发?