1
0
mirror of https://github.com/Llewellynvdm/Backup-System.git synced 2024-12-04 22:53:12 +00:00

Added error checking for the move

This commit is contained in:
Llewellyn van der Merwe 2018-07-09 23:26:08 +02:00
parent 9bfdc2dab6
commit 4012767a04
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
2 changed files with 46 additions and 2 deletions

32
incl.sh
View File

@ -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"

16
main.sh
View File

@ -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