ok...i havn't tested it too well as i don't have much room on my hard disk (have to move some music files to another location)...
this should do the trick though
after looking at how tar works with the excludes i realized that it will only exclude files or a list of files contained in a file...
so what i did was quite simple...
using find i found all the files in the backed up directories that i wanted to exclude by using the particular extension...
once found they were added to a list...
once the list was compiled i then invoked tar using that list as an exclude list...
and here is what i got
Code:
#!/bin/bash
BACKUP_DIRS="/etc/
/root/
/home/
/var/log/"
EXCLUDE_BACKUP_EXT="iso
ogg
img
tgz
pdf
rar
tar
zip
exe
mpg
mpeg
avi
mov
gz"
BACKUP_FILENAME=`date '+%Y-%m-%d'`
BACKUP_DEST_DIR="/home/jbsnake/backups/"
cur_dir=`pwd`
echo "$EXCLUDE_BACKUP_EXT" > "${cur_dir}/excludelist.dat"
echo "$BACKUP_DIRS" > "${cur_dir}/dirs2backup.dat"
function create_exclude_list
{
until ! read dir
do
until ! read extension
do
find "${dir}" -name "*.${extension}" 2> /dev/null >> "${cur_dir}/excludedfiles.dat"
done < "${cur_dir}/excludelist.dat"
done < "${cur_dir}/dirs2backup.dat"
}
create_exclude_list
tar --exclude-from "${cur_dir}/excludedfiles.dat" -czvf "${BACKUP_DEST_DIR}${HOSTNAME}--${BACKUP_FILENAME}.tgz" ${BACKUP_DIRS}
hope this helps
