From f80d5db25b12eec536b3f16e53556bab7b8461c8 Mon Sep 17 00:00:00 2001 From: DecaTec Date: Fri, 12 Apr 2019 14:07:37 +0200 Subject: [PATCH 1/1] Small improvements --- NextcloudBackup.sh | 8 ++++---- NextcloudRestore.sh | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) 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 diff --git a/NextcloudRestore.sh b/NextcloudRestore.sh index 1669a18..06610d5 100644 --- a/NextcloudRestore.sh +++ b/NextcloudRestore.sh @@ -99,9 +99,7 @@ fi # Set maintenance mode # echo "Set maintenance mode for Nextcloud..." -cd "${nextcloudFileDir}" -sudo -u "${webserverUser}" php occ maintenance:mode --on -cd ~ +sudo -u "${webserverUser}" php ${nextcloudFileDir}/occ maintenance:mode --on echo "Done" echo -- 2.34.1