From 3b7722ab569cfa19a20a75d5ed9ebae1045a2d04 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 30 Jan 2019 10:13:36 -0700 Subject: [PATCH] quoted all variable expansions to handle spaces properly --- root/NCscripts/backup.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/root/NCscripts/backup.sh b/root/NCscripts/backup.sh index 0626109..b35e6f5 100755 --- a/root/NCscripts/backup.sh +++ b/root/NCscripts/backup.sh @@ -151,7 +151,7 @@ function checkExist { ### ncMaint - pass requested mode change type to NextCloud occ function ncMaint { - sudo -u ${webUser} php ${ncRoot}/occ maintenance:mode --$1 \ + sudo -u "${webUser}" php "${ncRoot}/occ maintenance:mode" --"$1" \ >> "$logFile" 2>&1 maintResult="$?" return "$maintResult" @@ -381,8 +381,8 @@ if [ -z "$webUser" ]; then exit 1 # Check if supplied webUser account exists elif [ -n "$webUser" ]; then - user_exists=$(id -u $webUser > /dev/null 2>&1; echo $?) - if [ $user_exists -ne 0 ]; then + user_exists=$(id -u "$webUser" > /dev/null 2>&1; echo $?) + if [ "$user_exists" -ne 0 ]; then echo -e "\n${err}The supplied webuser account (-u parameter) does not" \ "exist.${normal}\n" exit 1 @@ -705,18 +705,18 @@ if [ -z "$borgExclude" ]; then # borgExclude is empty echo -e "${info}[$(stamp)] --[INFO] Executing borg without exclusions --" \ "${normal}" >> "$logFile" - borg --show-rc create ${borgCreateParams} ::`date +%Y-%m-%d_%H%M%S` \ - ${xtraFiles[@]} \ - ${sqlDumpDir} ${ncDataDir} \ + borg --show-rc create "${borgCreateParams}" ::`date +%Y-%m-%d_%H%M%S` \ + "${xtraFiles[@]}" \ + "${sqlDumpDir}" "${ncDataDir}" \ 2>> "$logFile" else # borgExclude is not empty echo -e "${info}[$(stamp)] --[INFO] Executing borg with exclusions --" \ "${normal}" >> "$logFile" - borg --show-rc create ${borgCreateParams} --exclude-from ${borgExclude} \ + borg --show-rc create "${borgCreateParams}" --exclude-from "${borgExclude}" \ ::`date +%Y-%m-%d_%H%M%S` \ - ${xtraFiles[@]} \ - ${sqlDumpDir} ${ncDataDir} \ + "${xtraFiles[@]}" \ + "${sqlDumpDir}" "${ncDataDir}" \ 2>> "$logFile" fi @@ -741,7 +741,7 @@ if [ -n "$borgPrune" ]; then # parameters defined echo -e "${info}[$(stamp)] --[INFO] Executing borg prune operation --" \ "${normal}" >> "$logFile" - borg prune --show-rc -v ${borgPruneParams} ${borgPrune} \ + borg prune --show-rc -v ${borgPruneParams} "${borgPrune}" \ 2>> "$logFile" # check return-status pruneResult="$?"