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:
parent
2a5660056a
commit
9bfdc2dab6
2
incl.sh
2
incl.sh
@ -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
36
main.sh
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user