1
0
mirror of https://github.com/Llewellynvdm/Backup-System.git synced 2024-12-12 08:57:47 +00:00
Backup-System/main.sh

67 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
#/--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
# __ __ _ _____ _ _ __ __ _ _ _
# \ \ / / | | | __ \ | | | | | \/ | | | | | | |
# \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
# \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
# \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
# \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
# | |
# |_|
#/-------------------------------------------------------------------------------------------------------------------------------/
#
# @version 1.0.0
# @build 9th May, 2017
# @package Backup System
# @author Llewellyn van der Merwe <https://github.com/Llewellynvdm>
# @copyright Copyright (C) 2015. All Rights Reserved
# @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
#
#/-----------------------------------------------------------------------------------------------------------------------------/
### MAIN ###
function main () {
# backup the databases now
backupDB
# backup the websites now
backupWEB
}
# function to backup all DB's
function backupDB () {
while IFS=$'\t' read -r -a database
do
[[ "$database" =~ ^#.*$ ]] && continue
# zip the database
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
# start fresh
cd "$DIR"
# GO To remote server and do house cleaning
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEDBPATH"
}
# function to backup all WEB folders
function backupWEB () {
while IFS=$'\t' read -r -a foalder
do
[[ "$foalder" =~ ^#.*$ ]] && continue
# move the local folder & files to remote
moveWEB "${foalder[0]}" "${foalder[1]}"
done < $folderBuilder
# start fresh
cd "$DIR"
# GO To remote server and do house cleaning
ssh -tt -p '22' "$REMOTESSH" "$(typeset -f); remoteHouseCleaning $REMOTEWEBPATH"
}
# run the main only at the end!
main