Skip to main content

Thread: tar --exclude [bash]


i'm making backup script in bash. , i've been testing out, , of encryption , compression, becomes slow, i've decided exclude things.

first few lines of code go [using different folder names security]:
php code:
#! /bin/bash
files="music"
exclude="*.mp3"
echo compressing files...
mkdir backup
tar 
-pvczf backup/backup.tar.gz --exclude=$exclude $files log.txt
echo done
this works.

if change third line to:
php code:
exclude="music/somerandomartist/*" 
this works.

however, if try combine two, like:
php code:
exclude="*.mp3 music/somerandomartist/*" 
this doesn't work, , ends excluding nothing.

i've tried delimiting things commas instead of spaces, , still no more luck.

heh, i've tried lot of things, there's no point mentioning them all.

google no help, i'm hoping give me hand.

in advance.

i believe --exclude can handle 1 expression. nothing stops using several excludes. example:
code:
...  exclude1="music/somerandomartist/*"   exclude2="*.mp3"  tar -pvczf backup/backup.tar.gz --exclude=$exclude1 --exclude=$exclude2 $files > log.txt  ...
good luck!


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] tar --exclude [bash]


Ubuntu

Comments