Since it only has a function that targets full backup, does this imply that you're only after rman_full_bkp_* dirs?
As suggested by Schneidz, you should use this something like this instead:
Code:
case "$(date +%a)" in
or
Code:
TODAY=$(`date +%d%b`)
TODAY_DOTW=$(date +%a)
...
case "$TODAY_DOTW" in
...
It's a little confusing but this is how I could see things so far:
Code:
#!/bin/bash
# Backup logs are stored here
LOGBASE=/root/backup/log
# Get todays day like Mon, Tue and so on
TODAY=$(`date +%d%b`)
TODAY_DOTW=$(date +%a)
# Backup dirs; do not prefix /
BACKUP_ROOT_DIRS=(u04/Backup/Flash/rman_*_"$TODAY")
# Tape device name
TAPE="/dev/IBMtape0"
# Exclude file
TAR_ARGS=()
EXCLUDE_CONF=/root/.backup.exclude.conf
# Backup Log file
LOGFIILE=$LOGBASE/$TODAY.backup.log
# Path to binaries
TAR=/bin/tar
MT=/bin/mt
MKDIR=/bin/mkdir
# ------------------------------------------------------------------------
# Excluding files when using tar
# Create a file called $EXCLUDE_CONF using a text editor
# Add files matching patterns such as follows (regex allowed):
# home/vivek/iso
# home/vivek/*.cpp~
# ------------------------------------------------------------------------
[ -f "$EXCLUDE_CONF" ] && TAR_ARGS=(-X "$EXCLUDE_CONF")
#### Custom functions #####
# Make a full backup
full_backup() {
local old=$(pwd)
cd /
"$TAR" "${TAR_ARGS[@]}" -cvzpf "$TAPE" "$BACKUP_ROOT_DIRS" ## ????
"$MT" -f "$TAPE" rewind
"$MT" -f "$TAPE" offline
cd "$old"
}
# Make sure all dirs exits
verify_backup_dirs() {
local s=0
for d in "${BACKUP_ROOT_DIRS[@]}"; do
if [ ! -d "/$d" ]; then
echo "Error : /$d directory does not exits!"
s=1
fi
done
# if not; just die
[ "$s" -eq 1 ] && exit 1
}
#### Main logic ####
# Make sure log dir exits
[ ! -d "$LOGBASE" ] && "$MKDIR" -p "$LOGBASE"
# Verify dirs
verify_backup_dirs
# Okay let us strat backup procedure
case "$TODAY_DOTW" in
Sun|Tue|Wed|Thu|Fri|Sat)
full_backup
;;
*)
;;
esac >"$LOGFIILE" 2>&1