Skip to content
Snippets Groups Projects
Commit 20d5853c authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

fix backups without transfer

parent 41077828
No related branches found
No related tags found
1 merge request!36fix backups without transfer
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
# -------------------------------------------------------------------------------- # --------------------------------------------------------------------------------
# functions # FUNCTIONS
# -------------------------------------------------------------------------------- # --------------------------------------------------------------------------------
function showHelp(){ function showHelp(){
...@@ -59,17 +59,15 @@ EOFhelp ...@@ -59,17 +59,15 @@ EOFhelp
} }
# -------------------------------------------------------------------------------- # --------------------------------------------------------------------------------
# checks # MAIN
# -------------------------------------------------------------------------------- # --------------------------------------------------------------------------------
# --- read backup config data
# --- read schedulerdata
j_read j_read
# --- handle params
while [ "$#" -gt 0 ]; while [ "$#" -gt 0 ];
do do
case "$1" in case "$1" in
-h|-\?|--help) -h|-\?|--help)
...@@ -120,33 +118,44 @@ do ...@@ -120,33 +118,44 @@ do
done done
# update logfile after param overrides # --- update logfile after param overrides
_j_setLogfile _j_setLogfile
# show infos # --------------------------------------------------------------------------------
# show infos
# --------------------------------------------------------------------------------
cfg_type=$(_j_getvar "${STORAGEFILE}" "type") cfg_type=$(_j_getvar "${STORAGEFILE}" "type")
cfg_full=$(_j_getvar "${STORAGEFILE}" "full") cfg_full=$(_j_getvar "${STORAGEFILE}" "full")
cfg_startfull=$(_j_getvar "${STORAGEFILE}" "start-time-full") cfg_startfull=$(_j_getvar "${STORAGEFILE}" "start-time-full")
test -z "${cfg_full}${cfg_startfull}" || cfg_info="INFO: Type is [auto]; ignoring config for full backup: [full = $cfg_full ... start-time-full = $cfg_startfull]" test -z "${cfg_full}${cfg_startfull}" || cfg_info="INFO: Type is [auto]; ignoring config for full backup: [full = $cfg_full ... start-time-full = $cfg_startfull]"
JOBDEF_STARTTIME=$(date +%H%M) JOBDEF_STARTTIME=$(date +%H%M)
STORAGE_BIN=$( _j_getvar "${STORAGEFILE}" "bin" ) STORAGE_BIN=$( _j_getvar "${STORAGEFILE}" "bin" )
STORAGE_BASEDIR=$(_j_getvar "${STORAGEFILE}" "storage")
cat << EOFbackupinfo cat << EOFbackupinfo
CONFIG: CONFIG:
Used Backup tool : $STORAGE_BIN Used Backup tool : $STORAGE_BIN
Backup type : $(_j_getvar ${STORAGEFILE} "type") Backup type : $(_j_getvar ${STORAGEFILE} "type")
$( test "$cfg_type" = "auto" && echo "$cfg_info" )$( test "$cfg_type" = "auto" || echo "INFO: full backup: $cfg_info" ) $( test "$cfg_type" = "auto" && echo "$cfg_info" )$( test "$cfg_type" = "auto" || echo "INFO: full backup: $cfg_info" )
EFFECTIVE: EFFECTIVE:
type : $JOBDEF_TYPE $JOBDEF_AUTO type : $JOBDEF_TYPE $JOBDEF_AUTO
donefile : $JOB_DONEFILE log : $JOB_LOGFILE
log : $JOB_LOGFILE
target : ${STORAGE_BASEDIR}$( test -z "$STORAGE_BASEDIR" && echo "NONE (local backup dumps only; no transfer)")
EOFbackupinfo EOFbackupinfo
test -z "$STORAGE_BASEDIR" || (
echo " dirs to transfer : "
j_getDirs2Backup | sed "s#^# #g"
echo
)
j_requireUser "root" j_requireUser "root"
# -------------------------------------------------------------------------------- # --------------------------------------------------------------------------------
...@@ -157,7 +166,9 @@ EOFbackupinfo ...@@ -157,7 +166,9 @@ EOFbackupinfo
sleep 3 sleep 3
# ----- local dumps # ------------------------------------------------------------
# local dumps
# ------------------------------------------------------------
echo "INFO: $(date) - starting backup ... type $JOBDEF_TYPE - time $JOBDEF_STARTTIME " | tee -a "$JOB_LOGFILE" echo "INFO: $(date) - starting backup ... type $JOBDEF_TYPE - time $JOBDEF_STARTTIME " | tee -a "$JOB_LOGFILE"
touch "${JOB_DONEFILE}.01.START" touch "${JOB_DONEFILE}.01.START"
...@@ -168,12 +179,14 @@ EOFbackupinfo ...@@ -168,12 +179,14 @@ EOFbackupinfo
"${DIR_SELF}"/localdump.sh ALL | tee -a "$JOB_LOGFILE" "${DIR_SELF}"/localdump.sh ALL | tee -a "$JOB_LOGFILE"
rcBackup=$? rcBackup=$?
echo "INFO: $(date) - local backups were finished" | tee -a "$JOB_LOGFILE" echo "INFO: $(date) - local backups were finished" | tee -a "$JOB_LOGFILE"
echo
sleep 2 sleep 2
# ----- transfer # ------------------------------------------------------------
# transfer
# ------------------------------------------------------------
if [ -x "${DIR_SELF}/transfer.sh" ]; then if [ -n "$STORAGE_BASEDIR" ] && [ -x "${DIR_SELF}/transfer.sh" ]; then
# transfer files # transfer files
cat "$STORAGEFILE" >>"$JOB_LOGFILE" cat "$STORAGEFILE" >>"$JOB_LOGFILE"
...@@ -184,15 +197,18 @@ EOFbackupinfo ...@@ -184,15 +197,18 @@ EOFbackupinfo
rcTransfer=$? rcTransfer=$?
else else
echo "SKIP - transfer.sh not found; all files will be kept on local filesystem only" | tee -a "$JOB_LOGFILE" echo "SKIP - No backup of dirs to a backup target." | tee -a "$JOB_LOGFILE"
fi fi
rcBackup=$rcBackup+rcTransfer rcBackup=$rcBackup+rcTransfer
echo "INFO: $(date) - DONE" | tee -a "$JOB_LOGFILE" echo "INFO: $(date) - DONE" | tee -a "$JOB_LOGFILE"
touch "${JOB_DONEFILE}.03.DONE" touch "${JOB_DONEFILE}.03.DONE"
# ------------------------------------------------------------
# cleanup
# ------------------------------------------------------------
echo echo
echo "INFO: $(date) - compress older logs" echo "INFO: $(date) - compress older logs"
echo find "${DIR_LOGS}" -name "*.log" -mtime +2 -print -exec gzip {} \; echo find "${DIR_LOGS}" -name "*.log" -mtime +2 -print -exec gzip {} \;
...@@ -204,6 +220,10 @@ EOFbackupinfo ...@@ -204,6 +220,10 @@ EOFbackupinfo
find "${DIR_LOGS}" -mtime +28 -delete -print find "${DIR_LOGS}" -mtime +28 -delete -print
echo echo
# ------------------------------------------------------------
# finish
# ------------------------------------------------------------
echo STATUS $0 exit with final returncode rc=$rcBackup | tee -a "$JOB_LOGFILE" echo STATUS $0 exit with final returncode rc=$rcBackup | tee -a "$JOB_LOGFILE"
echo echo
echo "log for this executed job is" echo "log for this executed job is"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment