mirror of
https://github.com/Llewellynvdm/Backup-System.git
synced 2024-12-12 08:57:47 +00:00
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:
parent
296c37cddc
commit
4212d5ee49
@ -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"
|
||||
|
||||
|
19
main.sh
19
main.sh
@ -19,9 +19,18 @@
|
||||
#
|
||||
#/-----------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
#confirm we are done
|
||||
#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
|
||||
if [ "$BACKUPDATABASE" -eq "1" ]; then
|
||||
backupDB
|
||||
fi
|
||||
# backup the websites now
|
||||
if [ "$BACKUPWEBSITES" -eq "1" ]; then
|
||||
backupWEB
|
||||
fi
|
||||
else
|
||||
# revert the databases now
|
||||
if [ "$BACKUPDATABASE" -eq "1" ]; then
|
||||
revertDB
|
||||
fi
|
||||
# revert the websites now
|
||||
if [ "$BACKUPWEBSITES" -eq "1" ]; then
|
||||
revertWEB
|
||||
fi
|
||||
# force remove tmp
|
||||
rmTmp 4
|
||||
fi
|
||||
|
24
run.sh
24
run.sh
@ -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,6 +77,8 @@ then
|
||||
mkdir -p "$tmpFolder"
|
||||
fi
|
||||
|
||||
# only add if db's are required
|
||||
if [ "$BACKUPDATABASE" -eq "1" ]; then
|
||||
# DB file
|
||||
databasesFileName="databases"
|
||||
databaseBuilder="$BASEDIR/$databasesFileName"
|
||||
@ -67,7 +87,10 @@ if [ ! -f "$databaseBuilder" ]
|
||||
then
|
||||
runSetup 2 "$databaseBuilder"
|
||||
fi
|
||||
fi
|
||||
|
||||
# only add if db's are required
|
||||
if [ "$BACKUPWEBSITES" -eq "1" ]; then
|
||||
# folder names
|
||||
foldersFileName="folders"
|
||||
folderBuilder="$BASEDIR/$foldersFileName"
|
||||
@ -76,6 +99,7 @@ if [ ! -f "$folderBuilder" ]
|
||||
then
|
||||
runSetup 3 "$folderBuilder"
|
||||
fi
|
||||
fi
|
||||
|
||||
# we move to user folder
|
||||
cd "$USERHOME"
|
||||
|
44
setup.sh
44
setup.sh
@ -69,28 +69,59 @@ function runSetupConfig () {
|
||||
# set default dropbox details
|
||||
INPUT_DROPBOX="/home/path/to/Dropbox-Uploader/dropbox_uploader.sh"
|
||||
fi
|
||||
# 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 Website Backups\n"
|
||||
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 Website Backup Type\n"
|
||||
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\n"
|
||||
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"
|
||||
@ -100,6 +131,9 @@ function runSetupConfig () {
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user