创建.tar.gz文件时排除目录 [英] Excluding directory when creating a .tar.gz file

查看:155
本文介绍了创建.tar.gz文件时排除目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 / public_html / 文件夹,在该文件夹有一个 / tmp / 文件夹有70gb

I have a /public_html/ folder, in that folder there's a /tmp/ folder that has like 70gb of files I don't really need.

现在我想创建一个 .tar.gz code> / public_html / 排除 / tmp /

Now I am trying to create a .tar.gz of /public_html/ excluding /tmp/

命令我运行:

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

tar仍在创建中,通过执行 ls -sh 我可以看到 MyBackup.tar.gz 已经有大约30gb,我知道<$ c $没有 / tmp / 的文件没有超过1GB的文件。

The tar is still being created, and by doing an ls -sh I can see that MyBackup.tar.gz already has about 30gb, and I know for sure that /public_html/ without /tmp/ doesn't have more than 1GB of files.

我做错了什么?

推荐答案

尝试删除目录路径末尾的last / / p>

Try removing the last / at the end of the directory path to exclude

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

这篇关于创建.tar.gz文件时排除目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆