From 80b174a05b6ffcc8cc4dc6b5dc4dc01949bc71ef Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Mon, 5 Jun 2017 17:54:16 +0100 Subject: [PATCH] added the date switch and updated the readme with clone details --- README.md | 8 +++++++- config.txt | 3 +++ incl.sh | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0638ad0..617cf19 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,19 @@ The Bash scripts used to backup database and folders on a server ## Getting started +Clone Repository + +```bash + $ git clone ssh://git@projects.vdm.io/system-backup.git system-backup +``` + Rename __config.txt__ to __config.sh__ and update the values in the file. ```bash $ mv config.txt config.sh ``` -Rename __folders.txt__ to __folders__ and update the values in the file. +Rename __folders.txt__ to __folders__ and update the values in the file. ```bash $ mv folders.txt folders diff --git a/config.txt b/config.txt index 445a685..0621f40 100644 --- a/config.txt +++ b/config.txt @@ -12,3 +12,6 @@ REMOTESSH="user@yourserver.com" REMOTEDBPATH="your_db_path/" REMOTEWEBPATH="your_website_pat/" +## 0 = no date | 1 = year | 2 = year-month | 3 = your-month-day | 4 = your-month-day:time # For DB file name +USEDATE=0 + diff --git a/incl.sh b/incl.sh index ea42899..2bf9b94 100755 --- a/incl.sh +++ b/incl.sh @@ -31,8 +31,22 @@ function zipDB { cd "$tmpFolder" # db server ip address DBSERVER="$1" + # check if date use is set + if [ -z ${USEDATE+x} ]; then + USEDATE=0 + fi # set the file name - FILE=`date +"%Y%m"`"_$2.sql" + if [ "$USEDATE" -eq "4" ]; then + FILE=`date +"%Y-%m-%d:%H:%M:%S"`"_$2.sql" + elif [ "$USEDATE" -eq "3" ]; then + FILE=`date +"%Y-%m-%d"`"_$2.sql" + elif [ "$USEDATE" -eq "2" ]; then + FILE=`date +"%Y-%m"`"_$2.sql" + elif [ "$USEDATE" -eq "1" ]; then + FILE=`date +"%Y"`"_$2.sql" + else + FILE="$2.sql" + fi #database to backup DATABASE="$3" # user that has access to do this