bash tar:使用 -X 时从成员名称中删除前导 /(排除文件)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19072345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 08:05:39  来源:igfitidea点击:

tar: Remove leading / from member names when using -X (exclude file)

bashtar

提问by chrisrth

I am getting the error:

我收到错误:

Remove leading / from member names 

when attempting to create a domain archive using -X and a exclude file. If I remove the -X option the job executes as expected.

尝试使用 -X 和排除文件创建域存档时。如果我删除 -X 选项,作业将按预期执行。

backup exec

备份执行

/mnt/15326/s3/backup.sh

tmp dir

目录

/mnt/15326/s3/data

exclude file

排除文件

/mnt/15326/s3/data/exclude.txt

with contents

有内容

/mnt/15326/www.domain.com/dir1
/mnt/15326/www.domain.com/dir2

dir to backup

要备份的目录

/mnt/15326/www.domain.com

command to run

命令运行

tar cf /mnt/15326/s3/data/backup_domain.com -X /mnt/15326/s3/data/exclude.txt /mnt/15326/www.domain.com

回答by Lajos Veres

It is a warning only. It means that in the tar file the file names wont contain the beginning /. They will be converted to relatives. Use -P if it disturbs you. generaly this default behaviour is a bit safer.

这只是一个警告。这意味着在 tar 文件中,文件名不会包含开头的 /。他们将被转换为亲戚。如果打扰您,请使用 -P。一般来说,这种默认行为更安全一些。