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

Made even more improvments on the tmp removal function

This commit is contained in:
Llewellyn van der Merwe 2018-07-06 00:36:45 +02:00
parent 2a5660056a
commit 9bfdc2dab6
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
2 changed files with 23 additions and 15 deletions

View File

@ -118,7 +118,7 @@ function remoteHouseCleaning () {
}
# remove a folder and all its content
function rmTmpFolder () {
function rmFolder () {
local FOLDER="$1"
# ensure repos is removed
if [ -d "$FOLDER" ]

36
main.sh
View File

@ -26,11 +26,27 @@ BACKUPWEBDONE=0
### MAIN ###
function main () {
# backup the databases now
backupDB &
backupDB
# backup the websites now
backupWEB
}
function rmTmp () {
# trip the switch for the done area
if [ "$1" -eq "1" ]; then
#confirm we are done
BACKUPDBDONE=1
elif [ "$1" -eq "2" ]; then
#confirm we are done
BACKUPWEBDONE=1
fi
# only if both are done
if [ "$BACKUPWEBDONE" -eq "1" ] && [ "$BACKUPDBDONE" -eq "1" ]; then
# now remove the local file
rmFolder "$tmpFolder"
fi
}
# function to backup all DB's
function backupDB () {
while IFS=$'\t' read -r -a database
@ -48,10 +64,8 @@ function backupDB () {
if [ "$BACKUPTYPE" -eq "1" ]; then
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEDBPATH"
fi
#confirm we are done
BACKUPDBDONE=1
# try to remove tmp
rmTmp
rmTmp 1
}
# function to backup all WEB folders
@ -71,18 +85,12 @@ function backupWEB () {
if [ "$BACKUPTYPE" -eq "1" ]; then
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEWEBPATH"
fi
#confirm we are done
BACKUPWEBDONE=1
# try to remove tmp
rmTmp
}
function rmTmp () {
if [ "$BACKUPWEBDONE" -eq "1" ] && [ "$BACKUPDBDONE" -eq "1" ]; then
# now remove the local file
rmTmpFolder "$tmpFolder"
fi
rmTmp 2
}
# run the main only at the end!
main
# try again
rmTmp 3