Backup script: Copying and removing directories based on list

I am writing a simple backup script, but I cannot figure out how to remove directories that are found in a list. For example:

DONT_COPY="
.adobe/
.bin/google-earth
" 

tar -zcvf - * --exclude=$DONT_COPY | openssl des3 -salt -k $1 | dd of=$(hostname)-$(date +%Y%m%d).tbz > COPIED

Note that this example does not work, I need to translate the DONT_COPY list to a better format. How can I do that?

Later in the script I compare the list of items in COPIED to a DO_COPY list so that the user could examine them at his leisure and decide whether or not to include them in future backups.

If on linux, you can either use --exclude-from and add the files to exclude into the file or you will have to use one --exclude for each pattern you want to exclude from tar.

$cat files_to_exclude
.adobe/
.bin/google-earth
$ tar -zcf --exclude-from=files_to_exclude file.tgz *

OR

$ tar -zcf --exclude=.adobe --exclude=bin/google-earth file.tgz *

Thanks, agn. How can I treat the DONT_COPY variable as a file, or alternatively, can I expand it to add the --exclude= text before all entries?

Try

$ for pattern in $DONT_COPY ; do echo -n "--exclude=$pattern "; done

Thanks! I had to change that to write to a variable, as it is in a script:

DONT_COPY_LIST=""
for pattern in $DONT_COPY ; do DONT_COPY_LIST="$DONT_COPY_LIST --exclude=$pattern "; done

However, it fails on spaces. The linux-wife balance is greatly upset by demanding no spaces in filenames, so the DONT_COPY list looks more like this (sorry that I did not think of this earlier):

DONT_COPY="
.adobe/
File with Spaces
.bin/google-earth
Yet Another Annoying Filename
" 

I tried replacing DONT_COPY in the second line with quotes, but this did not help (it created a different problem). How can I work with spaces in filenames?

I appreciate your patience and advice. I have googled this, but I can find no examples in which one is working with a list like this.

---------- Post updated at 11:30 PM ---------- Previous update was at 07:10 PM ----------

I got it with some help on a LUG mailing list:

EXCLUDES=`tempfile`
cat >$EXCLUDES <<EOLIST
$DONT_COPY
EOLIST

tar -zcvf - *  --exclude-from $EXCLUDES  | openssl des3 -salt -k $1 | dd of=$(hostname)-$(date +%Y%m%d).tbz

rm -f $EXCLUDES