diff --git a/incl.sh b/incl.sh index 3f692a1..887b23e 100644 --- a/incl.sh +++ b/incl.sh @@ -69,9 +69,15 @@ function moveDB () { # move file if [ "$BACKUPTYPE" -eq "2" ]; then $DROPBOX -q upload "$FILE" "${REMOTEDBPATH}${FILE}" + # to check the result + MOVEDBRESULT=$? else scp "$FILE" "$REMOTESSH:${REMOTEDBPATH}${FILE}" + # to check the result + MOVEDBRESULT=$? fi + # for global messages + MOVEDBWHAT="$FILE" } function moveWEB () { @@ -108,8 +114,32 @@ function moveWEB () { # move all file & folders if [ "$BACKUPTYPE" -eq "2" ]; then $DROPBOX -q upload "${PaTh}" "${remotePaTh}" + # to check the result + MOVEWEBRESULT=$? else rsync -ax "${PaTh}" "$REMOTESSH:${remotePaTh}" + # to check the result + MOVEWEBRESULT=$? + fi + # for global messages + MOVEWEBWHAT="${PaTh}" +} + +# do some error handling for the moving +function checkMove () { + # check the area + if [ "$1" -eq "1" ]; then + if [ $MOVEDBRESULT -ne 0 ]; then + echo "Database ${MOVEDBWHAT} could not be moved!" + else + echo "Database ${MOVEDBWHAT} where moved!" + fi + else + if [ $MOVEWEBRESULT -ne 0 ]; then + echo "Website ${MOVEWEBWHAT} could not be not be moved!" + else + echo "Website ${MOVEWEBWHAT} where moved!" + fi fi } @@ -120,7 +150,7 @@ function remoteHouseCleaning () { # remove a folder and all its content function rmFolder () { local FOLDER="$1" - # ensure repos is removed + # ensure folder is removed if [ -d "$FOLDER" ] then rm -fR "$FOLDER" diff --git a/main.sh b/main.sh index 135907d..3fd5f4e 100644 --- a/main.sh +++ b/main.sh @@ -23,6 +23,14 @@ BACKUPDBDONE=0 BACKUPWEBDONE=0 +# some error handle +MOVEDBRESULT=0 +MOVEWEBRESULT=0 + +# for global messages +MOVEDBWHAT='None' +MOVEWEBWHAT='None' + ### MAIN ### function main () { # backup the databases now @@ -56,6 +64,8 @@ function backupDB () { DBFILE=$(zipDB "${database[0]}" "${database[1]}" "${database[2]}" "${database[3]}" "${database[4]}") # move to backup server moveDB "$DBFILE" + # check if move was success + checkMove 1 done < $databaseBuilder # start fresh @@ -76,7 +86,8 @@ function backupWEB () { [[ "$foalder" =~ ^#.*$ ]] && continue # move the local folder & files to remote moveWEB "${foalder[0]}" "${foalder[1]}" - + # check if move was success + checkMove 2 done < $folderBuilder # start fresh @@ -94,3 +105,6 @@ main # try again rmTmp 3 + +# We are done +exit 0 \ No newline at end of file