This is my current directory structure on my MacOSX-Machine:
kuli at fumpenwuppich in /volume/workspace on master [!?$]
$ ls -l
total 0
drwxr-xr-x 4 kuli staff 136 Nov 28 16:02 conf
drwxr-xr-x 3 kuli staff 102 Nov 28 16:23 html
drwxr-xr-x 3 kuli staff 102 Nov 28 13:06 legacy
drwxr-xr-x 11 kuli staff 374 Nov 28 15:41 vagrant.nginx
I want to create a tar.bz2-file as a backup, but without the sub directory 'legacy'.
I've tried multiple things:
tar cfjv --exclude 'legacy' ~/Dropbox/backup/kuli.20151128.tar.bz2 .
tar cfjv --exclude='legacy' ~/Dropbox/backup/kuli.20151128.tar.bz2 .
tar cfjv ~/Dropbox/backup/kuli.20151128.tar.bz2 --exclude legacy .
tar cfjv ~/Dropbox/backup/kuli.20151128.tar.bz2 --exclude=legacy .
tar cfjv ~/Dropbox/backup/kuli.20151128.tar.bz2 --exclude='legacy' .
tar cfjv ~/Dropbox/backup/kuli.20151128.tar.bz2 --exclude './legacy' .
tar cfjv ~/Dropbox/backup/kuli.20151128.tar.bz2 --exclude='./legacy' .
tar cfjv ~/Dropbox/backup/kuli.20151128.tar.bz2 --exclude 'workspace/legacy' .
and so on. I've also tried to put the exlude-switch at the end of the command.
But nothing worked. All commands ignore the exclude command at all.
How to achieve this?
According to man page options go before files and directories list:
tar {-c} [options] [files | directories]
Additionally -f
and --exclude
options require parameters: -f file
and --exclude pattern
.
So, in your case, this should work:
tar cjv --exclude 'legacy' -f ~/Dropbox/backup/kuli.20151128.tar.bz2 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With