From: DecaTec Date: Wed, 27 Dec 2017 10:30:36 +0000 (+0100) Subject: Merge pull request #4 from mmartinortiz/fix-deleting-old-backups X-Git-Tag: v1.0.0~23 X-Git-Url: https://git.p6c8.net/nextcloud-backup-restore.git/commitdiff_plain/21812d9a1b2011c2a27b56be71455d167318e138?hp=374a1bc67f0cd848e46bf3cb685c9c7fa880f762 Merge pull request #4 from mmartinortiz/fix-deleting-old-backups Fixed comparison arithmetic context and comparison order --- diff --git a/NextcloudBackup.sh b/NextcloudBackup.sh index 38de995..dae6e7f 100644 --- a/NextcloudBackup.sh +++ b/NextcloudBackup.sh @@ -126,11 +126,11 @@ echo # # Delete old backups # -if [ ${maxNrOfBackups} != 0 ] +if (( ${maxNrOfBackups} != 0 )) then nrOfBackups=$(ls -l ${backupMainDir} | grep -c ^d) - if [ ${maxNrOfBackups} > ${nrOfBackups} ] + if (( ${nrOfBackups} > ${maxNrOfBackups} )) then echo "Removing old backups..." ls -t ${backupMainDir} | tail -$(( nrOfBackups - maxNrOfBackups )) | while read dirToRemove; do