oehrlis / oudbase

OUD base environment scripts
Apache License 2.0
6 stars 1 forks source link

OUD Backup script does not work #64

Closed oehrlis closed 4 years ago

oehrlis commented 4 years ago

OUD Backup script oud_backup.sh does not work. it does remove old backups

oracle@eusoud:/u00/app/oracle/local/oudbase/bin/ [oud_eus] ./oud_backup_old.sh -v
2020-02-24_20:17:54  INFO : Load list of OUD instances
2020-02-24_20:17:54  INFO : Initiate backup for OUD instances oud_eus 
./oud_backup_old.sh: line 252: 08: value too great for base (error token is "08")
./oud_backup_old.sh: line 253: 08: value too great for base (error token is "08")
./oud_backup_old.sh: line 254: % (4+1): syntax error: operand expected (error token is "% (4+1)")
2020-02-24_20:17:54  INFO : Define backup set for week 08 as 
oehrlis commented 4 years ago

remove of old backup have to check variables to make sure the are defined korrekt.

oehrlis commented 4 years ago

It seems that there was an issue with date and NEW_WEEK

NEW_WEEKNO=$(date "+%U")
OLD_WEEKNO=$((${NEW_WEEKNO}-${KEEP}))
NEW_BACKUP_SET="backup_set$(( ${NEW_WEEKNO} % (${KEEP}+1)))"
OLD_BACKUP_SET="backup_set$(( ${OLD_WEEKNO} % (${KEEP}+1)))"

Date does create a number with zero prefix. Bash identified this as octal. Further calculation does not work. Make sure, that NEW_WEEKNO does not get a zero by adding a sed command

NEW_WEEKNO=$(date "+%U"|sed "s/^0*//g")
OLD_WEEKNO=$((${NEW_WEEKNO}-${KEEP}))
NEW_BACKUP_SET="backup_set$(( ${NEW_WEEKNO} % (${KEEP}+1)))"
OLD_BACKUP_SET="backup_set$(( ${OLD_WEEKNO} % (${KEEP}+1)))"

Beside this I've add a check to make sure, that nothing is deleted when OLD_BACKUP_SET is undefined.