mirror of
https://github.com/Llewellynvdm/Backup-System.git
synced 2024-12-04 22:53:12 +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
|
# remove a folder and all its content
|
||||||
function rmTmpFolder () {
|
function rmFolder () {
|
||||||
local FOLDER="$1"
|
local FOLDER="$1"
|
||||||
# ensure repos is removed
|
# ensure repos is removed
|
||||||
if [ -d "$FOLDER" ]
|
if [ -d "$FOLDER" ]
|
||||||
|
36
main.sh
36
main.sh
@ -26,11 +26,27 @@ BACKUPWEBDONE=0
|
|||||||
### MAIN ###
|
### MAIN ###
|
||||||
function main () {
|
function main () {
|
||||||
# backup the databases now
|
# backup the databases now
|
||||||
backupDB &
|
backupDB
|
||||||
# backup the websites now
|
# backup the websites now
|
||||||
backupWEB
|
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 to backup all DB's
|
||||||
function backupDB () {
|
function backupDB () {
|
||||||
while IFS=$'\t' read -r -a database
|
while IFS=$'\t' read -r -a database
|
||||||
@ -48,10 +64,8 @@ function backupDB () {
|
|||||||
if [ "$BACKUPTYPE" -eq "1" ]; then
|
if [ "$BACKUPTYPE" -eq "1" ]; then
|
||||||
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEDBPATH"
|
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEDBPATH"
|
||||||
fi
|
fi
|
||||||
#confirm we are done
|
|
||||||
BACKUPDBDONE=1
|
|
||||||
# try to remove tmp
|
# try to remove tmp
|
||||||
rmTmp
|
rmTmp 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# function to backup all WEB folders
|
# function to backup all WEB folders
|
||||||
@ -71,18 +85,12 @@ function backupWEB () {
|
|||||||
if [ "$BACKUPTYPE" -eq "1" ]; then
|
if [ "$BACKUPTYPE" -eq "1" ]; then
|
||||||
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEWEBPATH"
|
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEWEBPATH"
|
||||||
fi
|
fi
|
||||||
#confirm we are done
|
|
||||||
BACKUPWEBDONE=1
|
|
||||||
# try to remove tmp
|
# try to remove tmp
|
||||||
rmTmp
|
rmTmp 2
|
||||||
}
|
|
||||||
|
|
||||||
function rmTmp () {
|
|
||||||
if [ "$BACKUPWEBDONE" -eq "1" ] && [ "$BACKUPDBDONE" -eq "1" ]; then
|
|
||||||
# now remove the local file
|
|
||||||
rmTmpFolder "$tmpFolder"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# run the main only at the end!
|
# run the main only at the end!
|
||||||
main
|
main
|
||||||
|
|
||||||
|
# try again
|
||||||
|
rmTmp 3
|
||||||
|
Loading…
Reference in New Issue
Block a user