1
0
mirror of https://github.com/Llewellynvdm/Backup-System.git synced 2024-12-12 17:07:46 +00:00
Backup-System/run.sh

83 lines
2.6 KiB
Bash
Raw Normal View History

2017-06-05 16:23:04 +00:00
#!/bin/bash
#/--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
# __ __ _ _____ _ _ __ __ _ _ _
# \ \ / / | | | __ \ | | | | | \/ | | | | | | |
# \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
# \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
# \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
# \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
# | |
# |_|
#/-------------------------------------------------------------------------------------------------------------------------------/
#
2018-07-05 18:50:36 +00:00
# @version 2.0.0
2017-06-05 16:23:04 +00:00
# @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
#
#/-----------------------------------------------------------------------------------------------------------------------------/
2018-07-04 13:27:40 +00:00
# user home dir
USERHOME=~/
2017-06-05 16:23:04 +00:00
# get script path
DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" || "$DIR" == '.' ]]; then DIR="$PWD"; fi
2018-07-05 18:50:36 +00:00
# load setup incase
. "$DIR/setup.sh"
# config file
DIRconfig="$DIR/config.sh"
# check if file exist
if [ ! -f "$DIRconfig" ]
then
runSetup 1 "$DIRconfig"
fi
2017-06-05 16:23:04 +00:00
# load configuration file
. "$DIR/config.sh"
# load functions
. "$DIR/incl.sh"
2018-07-04 13:27:40 +00:00
# got to script folder
2017-06-05 16:23:04 +00:00
cd "$DIR"
2018-07-04 13:27:40 +00:00
# set Base Dir
BASEDIR="$PWD"
2017-06-05 16:23:04 +00:00
# get random folder name to avoid conflict
newFolder=$(getRandom)
# set this repo location
2018-07-05 21:43:04 +00:00
tmpFolder="${USERHOME}T3MPR3P0_${newFolder}"
2017-06-05 16:23:04 +00:00
# create tmp folder
2018-07-05 21:43:04 +00:00
if [ ! -d "$tmpFolder" ]
then
mkdir -p "$tmpFolder"
fi
2017-06-05 16:23:04 +00:00
# DB file
databasesFileName="databases"
2018-07-04 13:27:40 +00:00
databaseBuilder="$BASEDIR/$databasesFileName"
2017-06-05 16:23:04 +00:00
# check if file exist
if [ ! -f "$databaseBuilder" ]
then
2018-07-05 18:50:36 +00:00
runSetup 2 "$databaseBuilder"
2017-06-05 16:23:04 +00:00
fi
# folder names
foldersFileName="folders"
2018-07-04 13:27:40 +00:00
folderBuilder="$BASEDIR/$foldersFileName"
2017-06-05 16:23:04 +00:00
# check if file exist
2018-07-05 18:50:36 +00:00
if [ ! -f "$folderBuilder" ]
2017-06-05 16:23:04 +00:00
then
2018-07-05 18:50:36 +00:00
runSetup 3 "$folderBuilder"
2017-06-05 16:23:04 +00:00
fi
2018-07-04 13:27:40 +00:00
# we move to user folder
cd "$USERHOME"
2017-06-05 16:23:04 +00:00
# run main
2018-07-04 13:27:40 +00:00
. "$BASEDIR/main.sh"