Added the option to only do database or website/files incase you only want to do on or the other

This commit is contained in:
Llewellyn van der Merwe 2018-07-16 00:30:21 +02:00
parent 296c37cddc
commit 4212d5ee49
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
4 changed files with 135 additions and 52 deletions

View File

@ -11,6 +11,10 @@
## BACKUP TYPE (1 = REMOTE SERVER || 2 = DROPBOX)
BACKUPTYPE=1
## BACKUP AREAS
BACKUPWEBSITES=1
BACKUPDATABASE=1
## REMOTE SERVER DETAILS (1)
REMOTESSH="user@yourserver.com"

31
main.sh
View File

@ -19,9 +19,18 @@
#
#/-----------------------------------------------------------------------------------------------------------------------------/
#confirm we are done
BACKUPDBDONE=0
BACKUPWEBDONE=0
#confirm we are done with database backup
if [ "$BACKUPDATABASE" -eq "1" ]; then
BACKUPDBDONE=0
else
BACKUPDBDONE=1
fi
#confirm we are done with website backup
if [ "$BACKUPWEBSITES" -eq "1" ]; then
BACKUPWEBDONE=0
else
BACKUPWEBDONE=1
fi
# some error handle
MOVEDBRESULT=0
@ -36,14 +45,22 @@ function main () {
# do backup
if [ "$REVERT" -ne 1 ]; then
# backup the databases now
backupDB
if [ "$BACKUPDATABASE" -eq "1" ]; then
backupDB
fi
# backup the websites now
backupWEB
if [ "$BACKUPWEBSITES" -eq "1" ]; then
backupWEB
fi
else
# revert the databases now
revertDB
if [ "$BACKUPDATABASE" -eq "1" ]; then
revertDB
fi
# revert the websites now
revertWEB
if [ "$BACKUPWEBSITES" -eq "1" ]; then
revertWEB
fi
# force remove tmp
rmTmp 4
fi

52
run.sh
View File

@ -44,6 +44,24 @@ fi
# load functions
. "$DIR/incl.sh"
# check if the BACKUPWEBSITES area switches is set
if [ -z ${BACKUPWEBSITES+x} ]; then
echo "BACKUPWEBSITES=1" >> "$DIR/config.sh"
BACKUPWEBSITES=1
fi
# check if the BACKUPDATABASE area switches is set
if [ -z ${BACKUPDATABASE+x} ]; then
echo "BACKUPDATABASE=1" >> "$DIR/config.sh"
BACKUPDATABASE=1
fi
# need only continue if either one option is set
if [ "$BACKUPWEBSITES" -eq "0" ] && [ "$BACKUPDATABASE" -eq "0" ]; then
# We have no work here
exit 0
fi
# got to script folder
cd "$DIR"
# set Base Dir
@ -59,22 +77,28 @@ then
mkdir -p "$tmpFolder"
fi
# DB file
databasesFileName="databases"
databaseBuilder="$BASEDIR/$databasesFileName"
# check if file exist
if [ ! -f "$databaseBuilder" ]
then
runSetup 2 "$databaseBuilder"
# only add if db's are required
if [ "$BACKUPDATABASE" -eq "1" ]; then
# DB file
databasesFileName="databases"
databaseBuilder="$BASEDIR/$databasesFileName"
# check if file exist
if [ ! -f "$databaseBuilder" ]
then
runSetup 2 "$databaseBuilder"
fi
fi
# folder names
foldersFileName="folders"
folderBuilder="$BASEDIR/$foldersFileName"
# check if file exist
if [ ! -f "$folderBuilder" ]
then
runSetup 3 "$folderBuilder"
# only add if db's are required
if [ "$BACKUPWEBSITES" -eq "1" ]; then
# folder names
foldersFileName="folders"
folderBuilder="$BASEDIR/$foldersFileName"
# check if file exist
if [ ! -f "$folderBuilder" ]
then
runSetup 3 "$folderBuilder"
fi
fi
# we move to user folder

100
setup.sh
View File

@ -69,37 +69,71 @@ function runSetupConfig () {
# set default dropbox details
INPUT_DROPBOX="/home/path/to/Dropbox-Uploader/dropbox_uploader.sh"
fi
# get the remote database backup paths
echo -ne "\n Set Remote Backup Path for Database Backups\n"
echo -ne " # Default (db_path/): "
read -r INPUT_REMOTEDBPATH
# set default
INPUT_REMOTEDBPATH=${INPUT_REMOTEDBPATH:-'db_path/'}
# get the remote website backup paths
echo -ne "\n Set Remote Backup Path for Website Backups\n"
echo -ne " # Default (website_path/): "
read -r INPUT_REMOTEWEBPATH
# set default
INPUT_REMOTEWEBPATH=${INPUT_REMOTEWEBPATH:-'website_path/'}
# select the website backup type
echo -ne "\n Select the Website Backup Type\n"
echo -ne " 1 = per/file\n"
echo -ne " 2 = zipped package (default)\n"
echo -ne " # Make your selection [1/2]: "
read -r INPUT_WEBBACKUPTYPE
# set default
INPUT_WEBBACKUPTYPE=${INPUT_WEBBACKUPTYPE:-2}
# select the backup file name convention
echo -ne "\n Select the Backup File Name Convention\n"
echo -ne " 0 = add no date\n"
echo -ne " 1 = add only year (default)\n"
echo -ne " 2 = add year & month\n"
echo -ne " 3 = add year, month & day\n"
echo -ne " 4 = add year, month, day & time\n"
echo -ne " # Make your selection [1-4]: "
read -r INPUT_USEDATE
# set default
INPUT_USEDATE=${INPUT_USEDATE:-1}
# Check if there is database backups
INPUT_BACKUPDATABASE=1
echo ""
echo -ne "\n Would you like to Backup Database/s? [y/N]: "
read -r answer
if [[ $answer != "y" ]]; then
# set backup to null
INPUT_BACKUPDATABASE=0
fi
# only add if db backups are required
if [ "$INPUT_BACKUPDATABASE" -eq "1" ]; then
# get the remote database backup paths
echo -ne "\n Set Remote Backup Path for Database Backups\n"
echo -ne " # Default (db_path/): "
read -r INPUT_REMOTEDBPATH
# set default
INPUT_REMOTEDBPATH=${INPUT_REMOTEDBPATH:-'db_path/'}
else
INPUT_REMOTEDBPATH='db_path/'
fi
# Check if there is website backups
INPUT_BACKUPWEBSITES=1
echo ""
echo -ne "\n Would you like to backup Files/Website? [y/N]: "
read -r answer
if [[ $answer != "y" ]]; then
# set backup to null
INPUT_BACKUPWEBSITES=0
fi
# only add if website backups are required
if [ "$INPUT_BACKUPWEBSITES" -eq "1" ]; then
# get the remote website backup paths
echo -ne "\n Set Remote Backup Path for Files/Website Backups\n"
echo -ne " # Default (website_path/): "
read -r INPUT_REMOTEWEBPATH
# set default
INPUT_REMOTEWEBPATH=${INPUT_REMOTEWEBPATH:-'website_path/'}
# select the website backup type
echo -ne "\n Select the Files/Website Backup Type\n"
echo -ne " 1 = per/file\n"
echo -ne " 2 = zipped package (default)\n"
echo -ne " # Make your selection [1/2]: "
read -r INPUT_WEBBACKUPTYPE
# set default
INPUT_WEBBACKUPTYPE=${INPUT_WEBBACKUPTYPE:-2}
else
INPUT_REMOTEWEBPATH='website_path/'
INPUT_WEBBACKUPTYPE=2
fi
# need only ask this if either one option is set
if [ "$INPUT_BACKUPWEBSITES" -eq "1" ] || [ "$INPUT_BACKUPDATABASE" -eq "1" ]; then
# select the backup file name convention
echo -ne "\n Select the Backup File Name Convention for zip Packages\n"
echo -ne " 0 = add no date\n"
echo -ne " 1 = add only year (default)\n"
echo -ne " 2 = add year & month\n"
echo -ne " 3 = add year, month & day\n"
echo -ne " 4 = add year, month, day & time\n"
echo -ne " # Make your selection [1-4]: "
read -r INPUT_USEDATE
# set default
INPUT_USEDATE=${INPUT_USEDATE:-1}
else
INPUT_USEDATE=1
fi
# now add it all to the config file
echo "#!/bin/bash" > "$1"
@ -115,6 +149,10 @@ function runSetupConfig () {
echo "## BACKUP TYPE (1 = REMOTE SERVER || 2 = DROPBOX)" >> "$1"
echo "BACKUPTYPE=${INPUT_BACKUPTYPE}" >> "$1"
echo "" >> "$1"
echo "## BACKUP AREAS" >> "$1"
echo "BACKUPWEBSITES=${INPUT_BACKUPWEBSITES}" >> "$1"
echo "BACKUPDATABASE=${INPUT_BACKUPDATABASE}" >> "$1"
echo "" >> "$1"
echo "## REMOTE SERVER DETAILS (1)" >> "$1"
echo "REMOTESSH=\"${INPUT_REMOTESSH}\"" >> "$1"
echo "" >> "$1"