如何在 Solaris 中运行 tar 时排除快照 [英] how to exclude snapshots while running tar in Solaris

查看:34
本文介绍了如何在 Solaris 中运行 tar 时排除快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取/home/store/"目录内容的 tar.

I'm trying to take a tar of the '/home/store/' directory content.

tar cvf store.tar /home/store/

这样做时,我可以看到 .snapshot 目录也被包含在内.我的理解是快照是一种备份.我可以跳过这个吗?如果可以,怎么做?尝试使用从/home/store/

While doing so, I can see that the .snapshot directories are also getting included. My understanding is that snapshots are kind of backups. Can I skip this? If possible, how? Tried excluding a test directory using the below command ran from /home/store/

tar cvfX store.tar <(echo /home/store/test) /home/store/

但这并没有从创建的 tar 中排除 test 目录.

But this is not excluding the test directory from the tar created.

也试过这个

tar cvf store.tar /home/store/ --exclude-file=exclude.txt

输出:

<代码>a/home/store//0K一个/home/store//.profile 1K一个/home/store//local.profile 1K一个/home/store//.vas_logon_server 1K一个/home/store//.vas_disauthcc_611400381 1K一个/home/store//.bash_history 7K一个/home/store//test/0K一个/home/store//test/1.txt 1Ka/home/store//test/migrate-perf3.txt 3958K一个/home/store//test.txt 1K一个/home/store//exclude.txt 1Ka/home/store//.snapshot/hourly.0/d2/dd/d5d/f82-1 59Ka/home/store//.snapshot/hourly.0/d2/dd/d5d/f83-1 58K.....tar: --exclude-file=exclude.txt: 没有那个文件或目录

/home/store/exclude.txt 有条目test".也尝试输入以下内容并得到同样的错误.

/home/store/exclude.txt has the entry 'test'. Tried entering the following as well and got same error.

<代码>/home/store/test//home/store/test/1.txt

当我像这样给出exclude.txt"的完整路径时

When I gave the full path to 'exclude.txt' like this

`tar cvf store.tar /home/store/ --exclude-file=/home/store/exclude.txt`

出现以下错误

tar: 无法将目录更改为 --exclude-file=/home/store: 没有这样的文件或目录

tar -h

用法:tar {c|r|t|u|x}[BDeEFhilmnopPqTvw@[0-7]][bfk][X...] [blocksize] [tarfile] [size] [exclude-文件...] {文件 |-I 包含文件 |-C 目录文件}...

提前致谢!
范佩尔

Thanks well in advance!
Van Peer

推荐答案

尝试这样做:

tar cvfX/var/tmp/src.tar/var/tmp/excl.txt/var/tmp/src/

tar cvfX /var/tmp/src.tar /var/tmp/excl.txt /var/tmp/src/

您的排除文件应包含路径:

Your exclude file should contain path:

/home/store//.快照

/home/store//.snapshot

最佳做法是不要使用 tar 目录的完整路径,因为将来您可以覆盖/etc ,例如从/var/tmp 提取 tar 存档时.

Best practice not to use full path of your tar dir, because in future you can overwite your /etc , when extract tar archive from /var/tmp, for example.

这篇关于如何在 Solaris 中运行 tar 时排除快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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