mirror of
https://github.com/Llewellynvdm/Backup-System.git
synced 2024-12-04 22:53:12 +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)
|
## BACKUP TYPE (1 = REMOTE SERVER || 2 = DROPBOX)
|
||||||
BACKUPTYPE=1
|
BACKUPTYPE=1
|
||||||
|
|
||||||
|
## BACKUP AREAS
|
||||||
|
BACKUPWEBSITES=1
|
||||||
|
BACKUPDATABASE=1
|
||||||
|
|
||||||
## REMOTE SERVER DETAILS (1)
|
## REMOTE SERVER DETAILS (1)
|
||||||
REMOTESSH="user@yourserver.com"
|
REMOTESSH="user@yourserver.com"
|
||||||
|
|
||||||
|
23
main.sh
23
main.sh
@ -19,9 +19,18 @@
|
|||||||
#
|
#
|
||||||
#/-----------------------------------------------------------------------------------------------------------------------------/
|
#/-----------------------------------------------------------------------------------------------------------------------------/
|
||||||
|
|
||||||
#confirm we are done
|
#confirm we are done with database backup
|
||||||
BACKUPDBDONE=0
|
if [ "$BACKUPDATABASE" -eq "1" ]; then
|
||||||
BACKUPWEBDONE=0
|
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
|
# some error handle
|
||||||
MOVEDBRESULT=0
|
MOVEDBRESULT=0
|
||||||
@ -36,14 +45,22 @@ function main () {
|
|||||||
# do backup
|
# do backup
|
||||||
if [ "$REVERT" -ne 1 ]; then
|
if [ "$REVERT" -ne 1 ]; then
|
||||||
# backup the databases now
|
# backup the databases now
|
||||||
|
if [ "$BACKUPDATABASE" -eq "1" ]; then
|
||||||
backupDB
|
backupDB
|
||||||
|
fi
|
||||||
# backup the websites now
|
# backup the websites now
|
||||||
|
if [ "$BACKUPWEBSITES" -eq "1" ]; then
|
||||||
backupWEB
|
backupWEB
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# revert the databases now
|
# revert the databases now
|
||||||
|
if [ "$BACKUPDATABASE" -eq "1" ]; then
|
||||||
revertDB
|
revertDB
|
||||||
|
fi
|
||||||
# revert the websites now
|
# revert the websites now
|
||||||
|
if [ "$BACKUPWEBSITES" -eq "1" ]; then
|
||||||
revertWEB
|
revertWEB
|
||||||
|
fi
|
||||||
# force remove tmp
|
# force remove tmp
|
||||||
rmTmp 4
|
rmTmp 4
|
||||||
fi
|
fi
|
||||||
|
48
run.sh
48
run.sh
@ -44,6 +44,24 @@ fi
|
|||||||
# load functions
|
# load functions
|
||||||
. "$DIR/incl.sh"
|
. "$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
|
# got to script folder
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
# set Base Dir
|
# set Base Dir
|
||||||
@ -59,22 +77,28 @@ then
|
|||||||
mkdir -p "$tmpFolder"
|
mkdir -p "$tmpFolder"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# DB file
|
# only add if db's are required
|
||||||
databasesFileName="databases"
|
if [ "$BACKUPDATABASE" -eq "1" ]; then
|
||||||
databaseBuilder="$BASEDIR/$databasesFileName"
|
# DB file
|
||||||
# check if file exist
|
databasesFileName="databases"
|
||||||
if [ ! -f "$databaseBuilder" ]
|
databaseBuilder="$BASEDIR/$databasesFileName"
|
||||||
then
|
# check if file exist
|
||||||
|
if [ ! -f "$databaseBuilder" ]
|
||||||
|
then
|
||||||
runSetup 2 "$databaseBuilder"
|
runSetup 2 "$databaseBuilder"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# folder names
|
# only add if db's are required
|
||||||
foldersFileName="folders"
|
if [ "$BACKUPWEBSITES" -eq "1" ]; then
|
||||||
folderBuilder="$BASEDIR/$foldersFileName"
|
# folder names
|
||||||
# check if file exist
|
foldersFileName="folders"
|
||||||
if [ ! -f "$folderBuilder" ]
|
folderBuilder="$BASEDIR/$foldersFileName"
|
||||||
then
|
# check if file exist
|
||||||
|
if [ ! -f "$folderBuilder" ]
|
||||||
|
then
|
||||||
runSetup 3 "$folderBuilder"
|
runSetup 3 "$folderBuilder"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# we move to user folder
|
# we move to user folder
|
||||||
|
44
setup.sh
44
setup.sh
@ -69,28 +69,59 @@ function runSetupConfig () {
|
|||||||
# set default dropbox details
|
# set default dropbox details
|
||||||
INPUT_DROPBOX="/home/path/to/Dropbox-Uploader/dropbox_uploader.sh"
|
INPUT_DROPBOX="/home/path/to/Dropbox-Uploader/dropbox_uploader.sh"
|
||||||
fi
|
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
|
# get the remote database backup paths
|
||||||
echo -ne "\n Set Remote Backup Path for Database Backups\n"
|
echo -ne "\n Set Remote Backup Path for Database Backups\n"
|
||||||
echo -ne " # Default (db_path/): "
|
echo -ne " # Default (db_path/): "
|
||||||
read -r INPUT_REMOTEDBPATH
|
read -r INPUT_REMOTEDBPATH
|
||||||
# set default
|
# set default
|
||||||
INPUT_REMOTEDBPATH=${INPUT_REMOTEDBPATH:-'db_path/'}
|
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
|
# 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/): "
|
echo -ne " # Default (website_path/): "
|
||||||
read -r INPUT_REMOTEWEBPATH
|
read -r INPUT_REMOTEWEBPATH
|
||||||
# set default
|
# set default
|
||||||
INPUT_REMOTEWEBPATH=${INPUT_REMOTEWEBPATH:-'website_path/'}
|
INPUT_REMOTEWEBPATH=${INPUT_REMOTEWEBPATH:-'website_path/'}
|
||||||
# select the website backup type
|
# 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 " 1 = per/file\n"
|
||||||
echo -ne " 2 = zipped package (default)\n"
|
echo -ne " 2 = zipped package (default)\n"
|
||||||
echo -ne " # Make your selection [1/2]: "
|
echo -ne " # Make your selection [1/2]: "
|
||||||
read -r INPUT_WEBBACKUPTYPE
|
read -r INPUT_WEBBACKUPTYPE
|
||||||
# set default
|
# set default
|
||||||
INPUT_WEBBACKUPTYPE=${INPUT_WEBBACKUPTYPE:-2}
|
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
|
# 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 " 0 = add no date\n"
|
||||||
echo -ne " 1 = add only year (default)\n"
|
echo -ne " 1 = add only year (default)\n"
|
||||||
echo -ne " 2 = add year & month\n"
|
echo -ne " 2 = add year & month\n"
|
||||||
@ -100,6 +131,9 @@ function runSetupConfig () {
|
|||||||
read -r INPUT_USEDATE
|
read -r INPUT_USEDATE
|
||||||
# set default
|
# set default
|
||||||
INPUT_USEDATE=${INPUT_USEDATE:-1}
|
INPUT_USEDATE=${INPUT_USEDATE:-1}
|
||||||
|
else
|
||||||
|
INPUT_USEDATE=1
|
||||||
|
fi
|
||||||
|
|
||||||
# now add it all to the config file
|
# now add it all to the config file
|
||||||
echo "#!/bin/bash" > "$1"
|
echo "#!/bin/bash" > "$1"
|
||||||
@ -115,6 +149,10 @@ function runSetupConfig () {
|
|||||||
echo "## BACKUP TYPE (1 = REMOTE SERVER || 2 = DROPBOX)" >> "$1"
|
echo "## BACKUP TYPE (1 = REMOTE SERVER || 2 = DROPBOX)" >> "$1"
|
||||||
echo "BACKUPTYPE=${INPUT_BACKUPTYPE}" >> "$1"
|
echo "BACKUPTYPE=${INPUT_BACKUPTYPE}" >> "$1"
|
||||||
echo "" >> "$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 "## REMOTE SERVER DETAILS (1)" >> "$1"
|
||||||
echo "REMOTESSH=\"${INPUT_REMOTESSH}\"" >> "$1"
|
echo "REMOTESSH=\"${INPUT_REMOTESSH}\"" >> "$1"
|
||||||
echo "" >> "$1"
|
echo "" >> "$1"
|
||||||
|
Loading…
Reference in New Issue
Block a user