From 9e5c741786a4bac1fc5db0f63b27c61c2888edeb Mon Sep 17 00:00:00 2001 From: mbomhoff Date: Tue, 28 Mar 2017 16:08:23 -0700 Subject: [PATCH] Fix loop counter in database backup removal --- scripts/backup/backup.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/backup/backup.sh b/scripts/backup/backup.sh index 59e3288bb..85111aed5 100755 --- a/scripts/backup/backup.sh +++ b/scripts/backup/backup.sh @@ -44,27 +44,25 @@ $ICMD/iput -bfr $LOCAL_MYSQL $REMOTE # echo `date` "Deleting old LOCAL database backups" #LOCAL_DELETIONS=`find $LOCAL/mysql_* -maxdepth 1 -type d -mtime +$DAYS_UNTIL_DELETE` -count=1 -for d in `ls -td /storage/coge/backup/*/ | grep 'mysql_'` +for d in `ls -td $LOCAL/*/ | grep 'mysql_'` do - if [ $count -gt $MAX_LOCAL_BACKUPS ]; + if [ $MAX_LOCAL_BACKUPS -le 0 ]; then echo deleting local $d rm -rf $d fi - ((count++)) + ((MAX_LOCAL_BACKUPS--)) done echo `date` "Deleting old REMOTE database backups (local & remote)" -count=1 -for d in `$ICMD/ils backup | grep 'mysql_' | sed 's/.*\(mysql_.*\)/\1/'` +for d in `$ICMD/ils $REMOTE | grep 'mysql_' | sed 's/.*\(mysql_.*\)/\1/'` do - if [ $count -gt $MAX_REMOTE_BACKUPS ]; + if [ $MAX_REMOTE_BACKUPS -le 0 ]; then echo deleting IRODS backup/$d $ICMD/irm -r backup/$d fi - ((count++)) + ((MAX_REMOTE_BACKUPS--)) done #