如何在Solaris中运行tar时排除快照

时间:2017-09-04 11:24:31

标签: solaris tar

我正在尝试使用'/ home / store /'目录内容的tar。

> url = "https://www.rstudio.com/products/rstudio/download/"
> thepage<-xml2::read_html(url)
> html_node(thepage, ".downloads td a") %>% html_attr("href")
[1] "https://download1.rstudio.org/RStudio-1.0.153.exe"

在执行此操作时,我可以看到 .snapshot 目录也包含在内。我的理解是快照是一种备份。我可以跳过这个吗?如果可能,怎么样?尝试使用以下命令排除测试目录,从/ home / store /

运行
tar cvf store.tar /home/store/

但这并不是从创建的tar中排除测试目录。

另外,试过这个

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

输出:

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

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

a /home/store// 0K a /home/store//.profile 1K a /home/store//local.profile 1K a /home/store//.vas_logon_server 1K a /home/store//.vas_disauthcc_611400381 1K a /home/store//.bash_history 7K a /home/store//test/ 0K a /home/store//test/1.txt 1K a /home/store//test/migrate-perf3.txt 3958K a /home/store//test.txt 1K a /home/store//exclude.txt 1K a /home/store//.snapshot/hourly.0/d2/dd/d5d/f82-1 59K a /home/store//.snapshot/hourly.0/d2/dd/d5d/f83-1 58K ..... tar: --exclude-file=exclude.txt: No such file or directory

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

a /home/store// 0K

它给出了以下错误

a /home/store//.profile 1K

tar -h

a /home/store//local.profile 1K

提前感谢!
范佩尔

2 个答案:

答案 0 :(得分:1)

尝试这样做:

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

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

/家庭/存储//。快照

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

答案 1 :(得分:0)

例如:

sudo tar -zcvpf /backup/farm-backup-$(date +%d-%m-%Y).tar.gz  --exclude ".snapshots" --exclude ".cache"  farm 

在目录中未在命令/farm中使用反斜杠。从/home目录执行tar命令以备份“农场”用户。

用于在根/backup目录中进行备份。

操作系统:OpenSuse 15.1