mirror of
https://github.com/Llewellynvdm/Backup-System.git
synced 2024-12-12 08:57:47 +00:00
Adapted the script to run more stable
This commit is contained in:
parent
80b174a05b
commit
a1ccfe850c
@ -16,7 +16,7 @@ The Bash scripts used to backup database and folders on a server
|
||||
Clone Repository
|
||||
|
||||
```bash
|
||||
$ git clone ssh://git@projects.vdm.io/system-backup.git system-backup
|
||||
$ git clone ssh://git@github.com:vdm-io/Backup-System.git system-backup
|
||||
```
|
||||
|
||||
Rename __config.txt__ to __config.sh__ and update the values in the file.
|
||||
|
11
main.sh
Executable file → Normal file
11
main.sh
Executable file → Normal file
@ -22,7 +22,7 @@
|
||||
### MAIN ###
|
||||
function main () {
|
||||
# backup the databases now
|
||||
backupDB
|
||||
backupDB &
|
||||
# backup the websites now
|
||||
backupWEB
|
||||
}
|
||||
@ -36,12 +36,13 @@ function backupDB () {
|
||||
DBFILE=$(zipDB "${database[0]}" "${database[1]}" "${database[2]}" "${database[3]}" "${database[4]}")
|
||||
# move to backup server
|
||||
moveDB "$DBFILE"
|
||||
# now remove the local file
|
||||
rmTmpFolder "$tmpFolder"
|
||||
done < $databaseBuilder
|
||||
|
||||
# now remove the local file
|
||||
rmTmpFolder "$tmpFolder"
|
||||
|
||||
# start fresh
|
||||
cd "$DIR"
|
||||
cd "$USERHOME"
|
||||
# GO To remote server and do house cleaning
|
||||
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEDBPATH"
|
||||
}
|
||||
@ -57,7 +58,7 @@ function backupWEB () {
|
||||
done < $folderBuilder
|
||||
|
||||
# start fresh
|
||||
cd "$DIR"
|
||||
cd "$USERHOME"
|
||||
# GO To remote server and do house cleaning
|
||||
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEWEBPATH"
|
||||
}
|
||||
|
22
run.sh
Executable file → Normal file
22
run.sh
Executable file → Normal file
@ -19,6 +19,8 @@
|
||||
#
|
||||
#/-----------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
# user home dir
|
||||
USERHOME=~/
|
||||
# get script path
|
||||
DIR="${BASH_SOURCE%/*}"
|
||||
if [[ ! -d "$DIR" || "$DIR" == '.' ]]; then DIR="$PWD"; fi
|
||||
@ -29,14 +31,15 @@ if [[ ! -d "$DIR" || "$DIR" == '.' ]]; then DIR="$PWD"; fi
|
||||
# load functions
|
||||
. "$DIR/incl.sh"
|
||||
|
||||
# we move out of the script folder
|
||||
# got to script folder
|
||||
cd "$DIR"
|
||||
cd ../
|
||||
# set Base Dir
|
||||
BASEDIR="$PWD"
|
||||
|
||||
# get random folder name to avoid conflict
|
||||
newFolder=$(getRandom)
|
||||
# set this repo location
|
||||
tmpFolder="$PWD/T3MPR3P0_$newFolder"
|
||||
tmpFolder="$USERHOME/T3MPR3P0_$newFolder"
|
||||
# create tmp folder
|
||||
if [ ! -d "$tmpFolder" ]
|
||||
then
|
||||
@ -45,23 +48,26 @@ fi
|
||||
|
||||
# DB file
|
||||
databasesFileName="databases"
|
||||
databaseBuilder="$DIR/$databasesFileName"
|
||||
databaseBuilder="$BASEDIR/$databasesFileName"
|
||||
# check if file exist
|
||||
if [ ! -f "$databaseBuilder" ]
|
||||
then
|
||||
echo 'No databases.txt found'
|
||||
echo 'No databases filefound'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# folder names
|
||||
foldersFileName="folders"
|
||||
folderBuilder="$DIR/$foldersFileName"
|
||||
folderBuilder="$BASEDIR/$foldersFileName"
|
||||
# check if file exist
|
||||
if [ ! -f "$folderBuilder" ]
|
||||
then
|
||||
echo 'No folders.txt found'
|
||||
echo 'No folders folder found'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# we move to user folder
|
||||
cd "$USERHOME"
|
||||
|
||||
# run main
|
||||
. "$DIR/main.sh"
|
||||
. "$BASEDIR/main.sh"
|
||||
|
Loading…
Reference in New Issue
Block a user