shell scripts in linux
I'm using a script someone else wrote to do automated daily backup 'snapshots' of all the computers on my lan using ssh, cron, & rsync.
I have a directory with all my websites that I'd like to do snapshots of but I'd like to exclude all the subdirectories called 'extras' since all those dir's contain large .psd, .tif, .bmp & other large files not meant for the web. Is there a simple way to exclude all the 'extras' subdirs using the script below or is it a lot more involved than that?
#!/bin/sh -e
DIR_DATA="/opt/backup/remote-mount/SERVERNAME/SHARENAME"
DIR_BKUP_ROOT="/opt/backup/snapshot/SERVERNAME_SHARENAME"
# Assumes the existence of
#${DIR_BKUP_ROOT}/{Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday}
RM="/bin/rm"
CP="/bin/cp"
RSYNC="/usr/bin/rsync"
DATE="/bin/date"
[ -x $RM -a -x $CP -a -x $RSYNC -a -x $DATE ] || exit 1
TODAY=`$DATE +%A`
case "$TODAY" in
'Monday')
LASTNIGHT="Sunday"
PREVBACK="Saturday"
;;
'Tuesday')
LASTNIGHT="Monday"
PREVBACK="Sunday"
;;
'Wednesday')
LASTNIGHT="Tuesday"
PREVBACK="Monday"
;;
'Thursday')
LASTNIGHT="Wednesday"
PREVBACK="Tuesday"
;;
'Friday')
LASTNIGHT="Thursday"
PREVBACK="Wednesday"
;;
'Saturday')
LASTNIGHT="Friday"
PREVBACK="Thursday"
;;
'Sunday')
LASTNIGHT="Saturday"
PREVBACK="Friday"
;;
*)
echo "ERROR: Invalid day!"
exit 2
;;
esac
$RM -rf ${DIR_BKUP_ROOT}/$LASTNIGHT
$CP -al ${DIR_BKUP_ROOT}/$PREVBACK ${DIR_BKUP_ROOT}/$LASTNIGHT
$RSYNC -avze --delete ${DIR_DATA}/ ${DIR_BKUP_ROOT}/${LASTNIGHT}/
|