Added error checking for the move
This commit is contained in:
parent
9bfdc2dab6
commit
4012767a04
32
incl.sh
32
incl.sh
|
@ -69,9 +69,15 @@ function moveDB () {
|
||||||
# move file
|
# move file
|
||||||
if [ "$BACKUPTYPE" -eq "2" ]; then
|
if [ "$BACKUPTYPE" -eq "2" ]; then
|
||||||
$DROPBOX -q upload "$FILE" "${REMOTEDBPATH}${FILE}"
|
$DROPBOX -q upload "$FILE" "${REMOTEDBPATH}${FILE}"
|
||||||
|
# to check the result
|
||||||
|
MOVEDBRESULT=$?
|
||||||
else
|
else
|
||||||
scp "$FILE" "$REMOTESSH:${REMOTEDBPATH}${FILE}"
|
scp "$FILE" "$REMOTESSH:${REMOTEDBPATH}${FILE}"
|
||||||
|
# to check the result
|
||||||
|
MOVEDBRESULT=$?
|
||||||
fi
|
fi
|
||||||
|
# for global messages
|
||||||
|
MOVEDBWHAT="$FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveWEB () {
|
function moveWEB () {
|
||||||
|
@ -108,8 +114,32 @@ function moveWEB () {
|
||||||
# move all file & folders
|
# move all file & folders
|
||||||
if [ "$BACKUPTYPE" -eq "2" ]; then
|
if [ "$BACKUPTYPE" -eq "2" ]; then
|
||||||
$DROPBOX -q upload "${PaTh}" "${remotePaTh}"
|
$DROPBOX -q upload "${PaTh}" "${remotePaTh}"
|
||||||
|
# to check the result
|
||||||
|
MOVEWEBRESULT=$?
|
||||||
else
|
else
|
||||||
rsync -ax "${PaTh}" "$REMOTESSH:${remotePaTh}"
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +150,7 @@ function remoteHouseCleaning () {
|
||||||
# remove a folder and all its content
|
# remove a folder and all its content
|
||||||
function rmFolder () {
|
function rmFolder () {
|
||||||
local FOLDER="$1"
|
local FOLDER="$1"
|
||||||
# ensure repos is removed
|
# ensure folder is removed
|
||||||
if [ -d "$FOLDER" ]
|
if [ -d "$FOLDER" ]
|
||||||
then
|
then
|
||||||
rm -fR "$FOLDER"
|
rm -fR "$FOLDER"
|
||||||
|
|
16
main.sh
16
main.sh
|
@ -23,6 +23,14 @@
|
||||||
BACKUPDBDONE=0
|
BACKUPDBDONE=0
|
||||||
BACKUPWEBDONE=0
|
BACKUPWEBDONE=0
|
||||||
|
|
||||||
|
# some error handle
|
||||||
|
MOVEDBRESULT=0
|
||||||
|
MOVEWEBRESULT=0
|
||||||
|
|
||||||
|
# for global messages
|
||||||
|
MOVEDBWHAT='None'
|
||||||
|
MOVEWEBWHAT='None'
|
||||||
|
|
||||||
### MAIN ###
|
### MAIN ###
|
||||||
function main () {
|
function main () {
|
||||||
# backup the databases now
|
# backup the databases now
|
||||||
|
@ -56,6 +64,8 @@ function backupDB () {
|
||||||
DBFILE=$(zipDB "${database[0]}" "${database[1]}" "${database[2]}" "${database[3]}" "${database[4]}")
|
DBFILE=$(zipDB "${database[0]}" "${database[1]}" "${database[2]}" "${database[3]}" "${database[4]}")
|
||||||
# move to backup server
|
# move to backup server
|
||||||
moveDB "$DBFILE"
|
moveDB "$DBFILE"
|
||||||
|
# check if move was success
|
||||||
|
checkMove 1
|
||||||
done < $databaseBuilder
|
done < $databaseBuilder
|
||||||
|
|
||||||
# start fresh
|
# start fresh
|
||||||
|
@ -76,7 +86,8 @@ function backupWEB () {
|
||||||
[[ "$foalder" =~ ^#.*$ ]] && continue
|
[[ "$foalder" =~ ^#.*$ ]] && continue
|
||||||
# move the local folder & files to remote
|
# move the local folder & files to remote
|
||||||
moveWEB "${foalder[0]}" "${foalder[1]}"
|
moveWEB "${foalder[0]}" "${foalder[1]}"
|
||||||
|
# check if move was success
|
||||||
|
checkMove 2
|
||||||
done < $folderBuilder
|
done < $folderBuilder
|
||||||
|
|
||||||
# start fresh
|
# start fresh
|
||||||
|
@ -94,3 +105,6 @@ main
|
||||||
|
|
||||||
# try again
|
# try again
|
||||||
rmTmp 3
|
rmTmp 3
|
||||||
|
|
||||||
|
# We are done
|
||||||
|
exit 0
|
Loading…
Reference in New Issue