Just go into the parent of dir1..dir12, and do a directory listing, then pipe the output to a series of grep -v "dir-i-want-to-ignore" for the offending directories.
Then also grep -v for "total ##" with the last grep -v in there, then that output gets piped to the sed command which if you use my little regex will trim off everything before the file/foldername. You could modify this slightly to ignore files as well:
cp -rp `ls -l | grep -v "errors" | grep -v "sessions" | grep -v "databases" | grep -v "private" | grep -v "total" | sed s/.*:...//` ~/desination-for-copy/
So just replace "errors", "sessions" "databases", "private" etc with whatever. The grep -v "total" is required!
I did this as such to ignore logs/errors/session data and deployment settings when copying my web applicaiton, and I use it so much I made an alias for it. You can even add env variables after the cp and ls which holds the paths for the source/destination (just have to make sure you set it before you copy each time). Oh, and you could always replace one of the vars with a dot and just be sure to be in either the source or destination folder when you do the backup.
alias bu='cp -rp $BU_SRC/`ls -l $BU_SRC | grep -v "errors" | grep -v "sessions" | grep -v "databases" | grep -v "private" | grep -v "total" | sed s/.*:...//` $BU_DEST'
I realize you posted this a long time ago, but maybe it'll help someone?
EDIT: One more note -- if you don't know the names of the files you want to ignore ahead of time, this command could easily be used in a shell script that takes args for src dest ignore1..ignoreN
./cpignore . ~/backup sessions private databases
It wouldn't be that much effort even if you're not a shell scripter, and it'd be a good opportunity to learn how to do something simple like this.
Last edited by kasapo; 02-28-2011 at 01:53 PM.
Reason: idea for shellscript