how to exclude snapshots while running tar in Solaris

╄→гoц情女王★ 提交于 2019-12-13 02:50:41

问题


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

tar cvf store.tar /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/

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

Also, tried this

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

Output:

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

/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

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

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

it's giving the below error

tar: can't change directories to --exclude-file=/home/store: No such file or directory

tar -h

Usage: tar {c|r|t|u|x}[BDeEFhilmnopPqTvw@[0-7]][bfk][X...] [blocksize] [tarfile] [size] [exclude-file...] {file | -I include-file | -C directory file}...

Thanks well in advance!
Van Peer


回答1:


Try to do so:

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

Your exclude file should contain path:

/home/store//.snapshot

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.



来源:https://stackoverflow.com/questions/46035988/how-to-exclude-snapshots-while-running-tar-in-solaris

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!