Make local and sync tasks skipable.
This commit is contained in:
parent
6ede66fa5c
commit
242153b472
|
@ -36,8 +36,14 @@ SYSTEM=$(uname | tr '[:upper:]' '[:lower:]')
|
||||||
PIDFILE="/var/run/evobackup.pid"
|
PIDFILE="/var/run/evobackup.pid"
|
||||||
LOGFILE="/var/log/evobackup.log"
|
LOGFILE="/var/log/evobackup.log"
|
||||||
|
|
||||||
|
## Enable/Disable tasks
|
||||||
|
LOCAL_TASKS=1
|
||||||
|
SYNC_TASKS=1
|
||||||
|
|
||||||
##### SETUP AND FUNCTIONS #############################################
|
##### SETUP AND FUNCTIONS #############################################
|
||||||
|
|
||||||
|
BEGINNING=$(/bin/date +"%d-%m-%Y ; %H:%M")
|
||||||
|
|
||||||
# shellcheck disable=SC2174
|
# shellcheck disable=SC2174
|
||||||
mkdir -p -m 700 ${LOCAL_BACKUP_DIR}
|
mkdir -p -m 700 ${LOCAL_BACKUP_DIR}
|
||||||
|
|
||||||
|
@ -121,6 +127,7 @@ trap "rm -f ${PIDFILE}" EXIT
|
||||||
|
|
||||||
##### LOCAL BACKUP ####################################################
|
##### LOCAL BACKUP ####################################################
|
||||||
|
|
||||||
|
if [ "${LOCAL_TASKS}" = "1" ]; then
|
||||||
# You can comment or uncomment sections below to customize the backup
|
# You can comment or uncomment sections below to customize the backup
|
||||||
|
|
||||||
## OpenLDAP : example with slapcat
|
## OpenLDAP : example with slapcat
|
||||||
|
@ -263,6 +270,8 @@ else
|
||||||
##disklabel sd0 > ${LOCAL_BACKUP_DIR}/partitions
|
##disklabel sd0 > ${LOCAL_BACKUP_DIR}/partitions
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
##### REMOTE BACKUP ###################################################
|
##### REMOTE BACKUP ###################################################
|
||||||
|
|
||||||
n=0
|
n=0
|
||||||
|
@ -284,14 +293,14 @@ SSH_PORT=$(echo "${server}" | cut -d':' -f2)
|
||||||
|
|
||||||
HOSTNAME=$(hostname)
|
HOSTNAME=$(hostname)
|
||||||
|
|
||||||
BEGINNING=$(/bin/date +"%d-%m-%Y ; %H:%M")
|
|
||||||
|
|
||||||
if [ "${SYSTEM}" = "linux" ]; then
|
if [ "${SYSTEM}" = "linux" ]; then
|
||||||
rep="/bin /boot /lib /opt /sbin /usr"
|
rep="/bin /boot /lib /opt /sbin /usr"
|
||||||
else
|
else
|
||||||
rep="/bsd /bin /sbin /usr"
|
rep="/bsd /bin /sbin /usr"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ "${SYNC_TASKS}" = "1" ]; then
|
||||||
# /!\ DO NOT USE COMMENTS in the rsync command /!\
|
# /!\ DO NOT USE COMMENTS in the rsync command /!\
|
||||||
# It breaks the command and destroys data, simply remove (or add) lines.
|
# It breaks the command and destroys data, simply remove (or add) lines.
|
||||||
|
|
||||||
|
@ -334,15 +343,18 @@ rsync -avzh --stats --delete --delete-excluded --force --ignore-errors --partial
|
||||||
-e "ssh -p ${SSH_PORT}" \
|
-e "ssh -p ${SSH_PORT}" \
|
||||||
"root@${SSH_SERVER}:/var/backup/" \
|
"root@${SSH_SERVER}:/var/backup/" \
|
||||||
| tail -30 >> $LOGFILE
|
| tail -30 >> $LOGFILE
|
||||||
|
fi
|
||||||
END=$(/bin/date +"%d-%m-%Y ; %H:%M")
|
|
||||||
|
|
||||||
##### REPORTING #######################################################
|
##### REPORTING #######################################################
|
||||||
|
|
||||||
printf "EvoBackup - %s - START %s ON %s\n" "${HOSTNAME}" "${BEGINNING}" "${SSH_SERVER}" \
|
END=$(/bin/date +"%d-%m-%Y ; %H:%M")
|
||||||
|
|
||||||
|
printf "EvoBackup - %s - START %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\n" \
|
||||||
|
"${HOSTNAME}" "${BEGINNING}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
||||||
>> $LOGFILE
|
>> $LOGFILE
|
||||||
|
|
||||||
printf "EvoBackup - %s - STOP %s ON %s\n" "${HOSTNAME}" "${END}" "${SSH_SERVER}" \
|
printf "EvoBackup - %s - STOP %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\n" \
|
||||||
|
"${HOSTNAME}" "${END}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
||||||
>> $LOGFILE
|
>> $LOGFILE
|
||||||
|
|
||||||
tail -10 $LOGFILE | \
|
tail -10 $LOGFILE | \
|
||||||
|
|
Loading…
Reference in a new issue