From: DecaTec Date: Fri, 12 Apr 2019 12:07:37 +0000 (+0200) Subject: Small improvements X-Git-Tag: v1.0.0~3 X-Git-Url: https://git.p6c8.net/nextcloud-backup-restore.git/commitdiff_plain/f80d5db25b12eec536b3f16e53556bab7b8461c8?hp=ef1ef85ac3afd35b16f402f4c35c860c99dc72e8 Small improvements --- 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