Closed oehrlis closed 4 years ago
remove of old backup have to check variables to make sure the are defined korrekt.
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.
OUD Backup script oud_backup.sh does not work. it does remove old backups