]> git.p6c8.net - nextcloud-backup-restore.git/blobdiff - NextcloudBackup.sh
Small improvements
[nextcloud-backup-restore.git] / NextcloudBackup.sh
index aeb31fb3c185f20870ce31cbbb550891a4c4d030..f433a8d9b4653ccebeeb9473e6a65a926e1da173 100644 (file)
@@ -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

patrick-canterino.de