X-Git-Url: https://git.p6c8.net/nextcloud-backup-restore.git/blobdiff_plain/ef1ef85ac3afd35b16f402f4c35c860c99dc72e8..f80d5db25b12eec536b3f16e53556bab7b8461c8:/NextcloudBackup.sh diff --git a/NextcloudBackup.sh b/NextcloudBackup.sh index aeb31fb..f433a8d 100644 --- a/NextcloudBackup.sh +++ b/NextcloudBackup.sh @@ -183,16 +183,16 @@ DisableMaintenanceMode # # Delete old backups # -if (( ${maxNrOfBackups} != 0 )) +if [ ${maxNrOfBackups} != 0 ] then nrOfBackups=$(ls -l ${backupMainDir} | grep -c ^d) - if (( ${nrOfBackups} > ${maxNrOfBackups} )) + if [[ ${nrOfBackups} > ${maxNrOfBackups} ]] then echo "Removing old backups..." - ls -t ${backupMainDir} | tail -$(( nrOfBackups - maxNrOfBackups )) | while read dirToRemove; do + ls -t ${backupMainDir} | tail -$(( nrOfBackups - maxNrOfBackups )) | while read -r dirToRemove; do echo "${dirToRemove}" - rm -r ${backupMainDir}/${dirToRemove} + rm -r "${backupMainDir}/${dirToRemove:?}" echo "Done" echo done