revert zzz_evobackup commit mistake
This commit is contained in:
parent
018392e8e3
commit
1f59065a17
|
@ -48,7 +48,7 @@ SYNC_TASKS=${SYNC_TASKS:-1}
|
||||||
|
|
||||||
##### SETUP AND FUNCTIONS #############################################
|
##### SETUP AND FUNCTIONS #############################################
|
||||||
|
|
||||||
BEGINNING=$(now)
|
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}
|
||||||
|
@ -65,18 +65,6 @@ umask 077
|
||||||
## Initialize variable to store SSH connection errors
|
## Initialize variable to store SSH connection errors
|
||||||
SERVERS_SSH_ERRORS=""
|
SERVERS_SSH_ERRORS=""
|
||||||
|
|
||||||
now() {
|
|
||||||
date +"%Y-%m-%dT%H:%M:%S%:z"
|
|
||||||
}
|
|
||||||
log_error() {
|
|
||||||
>&2 echo "$@"
|
|
||||||
printf "[%s] ERROR: %s\n" "$(now)" "$@" >> $LOGFILE
|
|
||||||
}
|
|
||||||
log_info() {
|
|
||||||
echo "$@"
|
|
||||||
printf "[%s] INFO: %s\n" "$(now)" "$@" >> $LOGFILE
|
|
||||||
}
|
|
||||||
|
|
||||||
# Call test_server with "HOST:PORT" string
|
# Call test_server with "HOST:PORT" string
|
||||||
# It will return with 0 if the server is reachable.
|
# It will return with 0 if the server is reachable.
|
||||||
# It will return with 1 and a message on stderr if not.
|
# It will return with 1 and a message on stderr if not.
|
||||||
|
@ -110,7 +98,10 @@ pick_server() {
|
||||||
new_error="No more server available"
|
new_error="No more server available"
|
||||||
SERVERS_SSH_ERRORS=$(printf "%s\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
SERVERS_SSH_ERRORS=$(printf "%s\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
||||||
|
|
||||||
log_error "${SERVERS_SSH_ERRORS}"
|
# Log errors to stderr
|
||||||
|
printf "%s\n" "${SERVERS_SSH_ERRORS}" >&2
|
||||||
|
# Log errors to logfile
|
||||||
|
printf "%s\n" "${SERVERS_SSH_ERRORS}" >> $LOGFILE
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -139,7 +130,7 @@ if [ -e "${PIDFILE}" ]; then
|
||||||
done
|
done
|
||||||
# Then kill the main PID.
|
# Then kill the main PID.
|
||||||
kill -9 "${pid}"
|
kill -9 "${pid}"
|
||||||
log_error $(printf "%s is still running (PID %s). Process has been killed" "$0" "${pid}")
|
printf "%s is still running (PID %s). Process has been killed" "$0" "${pid}\n" >&2
|
||||||
else
|
else
|
||||||
rm -f ${PIDFILE}
|
rm -f ${PIDFILE}
|
||||||
fi
|
fi
|
||||||
|
@ -151,7 +142,6 @@ trap "rm -f ${PIDFILE}" EXIT
|
||||||
##### LOCAL BACKUP ####################################################
|
##### LOCAL BACKUP ####################################################
|
||||||
|
|
||||||
if [ "${LOCAL_TASKS}" = "1" ]; then
|
if [ "${LOCAL_TASKS}" = "1" ]; then
|
||||||
log_info "Local tasks: start"
|
|
||||||
# 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
|
||||||
|
@ -329,9 +319,6 @@ if [ "${LOCAL_TASKS}" = "1" ]; then
|
||||||
#getfacl -R /usr > ${LOCAL_BACKUP_DIR}/rights-usr.txt
|
#getfacl -R /usr > ${LOCAL_BACKUP_DIR}/rights-usr.txt
|
||||||
#getfacl -R /home > ${LOCAL_BACKUP_DIR}/rights-home.txt
|
#getfacl -R /home > ${LOCAL_BACKUP_DIR}/rights-home.txt
|
||||||
|
|
||||||
log_info "Local tasks: finish"
|
|
||||||
else
|
|
||||||
log_info "Local tasks: skip"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##### REMOTE BACKUP ###################################################
|
##### REMOTE BACKUP ###################################################
|
||||||
|
@ -369,7 +356,6 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if [ "${SYNC_TASKS}" = "1" ]; then
|
if [ "${SYNC_TASKS}" = "1" ]; then
|
||||||
log_info "Sync tasks: start"
|
|
||||||
# /!\ 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.
|
||||||
|
|
||||||
|
@ -414,18 +400,18 @@ if [ "${SYNC_TASKS}" = "1" ]; then
|
||||||
-e "${RSH_COMMAND}" \
|
-e "${RSH_COMMAND}" \
|
||||||
"root@${SSH_SERVER}:/var/backup/" \
|
"root@${SSH_SERVER}:/var/backup/" \
|
||||||
| tail -30 >> $LOGFILE
|
| tail -30 >> $LOGFILE
|
||||||
|
|
||||||
log_info "Sync tasks: finish"
|
|
||||||
else
|
|
||||||
log_info "Sync tasks: skip"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##### REPORTING #######################################################
|
##### REPORTING #######################################################
|
||||||
|
|
||||||
END=$(now)
|
END=$(/bin/date +"%d-%m-%Y ; %H:%M")
|
||||||
|
|
||||||
log_info "EvoBackup - %s - START %s STOP %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\n" \
|
printf "EvoBackup - %s - START %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\n" \
|
||||||
"${HOSTNAME}" "${BEGINNING}" "${END}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
"${HOSTNAME}" "${BEGINNING}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
||||||
|
>> $LOGFILE
|
||||||
|
|
||||||
|
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