backup-rcopy/conf/rcopy_functions.conf

131 lines
2.5 KiB
Plaintext

#######################################################
## Functions for remote backupscript ##
#######################################################
# --------------------------------------------------- #
# ------------------- Funktionen -------------------- #
#
usage() {
[[ -n "$1" ]] && error "$1"
echo -e "
\033[1mUsage:\033[m
$(basename $0) [OPTION [OPTION ..
\033[1mDescription\033[m
Main Backup Script for hosts maintained by O.OPEN.
\033[1mOptions\033[m
-B
Only Backup host - do not handle (existing) archives.
-N
Do not backup anything, only maintain existing backups - archiving and/or
removing existing backups.
-m
Only backup hosts listed in file conf/manual_hosts.conf. Don't inform anyone,
and also don't restart services.
\033[1mFiles\033[m
\033[1m$(basename $rcopy_conf_file)\033[m: Main Configuration
See folder 'conf' for more configuration files
\033[1mExample:\033[m
Normal Backup
$(basename $0)
Only maintain backup archives - do NOT write new backups
$(basename $0) -N
"
clean_up 1
}
clean_up() {
# Perform program exit housekeeping
rm -rf "$LOCK_DIR"
blank_line
exit $1
}
echolog(){
if [ -n "$2" ];then
case $_DEBUG in
0)
if [ "$2" -eq 0 ]; then
echo -e "$1" >> $logFile
fi
;;
1)
if [ "$2" -lt 2 ]; then
echo -e "$1" >> $logFile
fi
;;
2)
echo -e "$1" >> $logFile
;;
*)
;;
esac
else
echo -e "$1" >> $logFile
fi
}
#
#
echononl(){
echo X\\c > /tmp/shprompt$$
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
# echo "$*\\c" 1>&2
echo "$*\\c" >> $logFile
else
# echo -e -n "$*" 1>&2
echo -e -n "$*" >> $logFile
fi
rm /tmp/shprompt$$
}
print_error_stdout() {
echo -e -n "\n Host: ${srcHost}\n Error: $*" 1>&2
echo ""
}
#
#
fatal(){
echolog "!!! The backup procedure was interrupted !!!"
echolog "\nError:\n\t $*"
echolog "\n*** End Update -- no backups are done ***\n\n"
exit 1
}
trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
blank_line() {
echo ""
}
#
# ------------------ Ende Funktionen ---------------- #
# --------------------------------------------------- #