logging
This commit is contained in:
1 parent
050c3ccd9e
commit
b079912dc7
8 files changed
+325
-104
No files matched your search
@@ -18,6 +18,17 @@ show_help() {
|
||||
echo " "
|
||||
}
|
||||
|
||||
#
|
||||
# Script muss unter root bzw. sudo laufen, sonst gibt es jede Menge Probleme
|
||||
# mit Zugriff auf die diversen Verzeichnisse.
|
||||
#
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "**"
|
||||
echo "** ERROR: script has to be run as superuser!"
|
||||
echo "**"
|
||||
exit 100
|
||||
fi
|
||||
|
||||
HERE=$(dirname "$0")
|
||||
|
||||
if [ -f $HERE/main.inc.sh ]; then
|
||||
@@ -28,7 +39,7 @@ else
|
||||
echo "** Script wird abgebrochen"
|
||||
echo "**"
|
||||
show_help
|
||||
exit 1
|
||||
exit 101
|
||||
fi
|
||||
|
||||
if [ -f $HERE/$HOST_NAME.sh ]; then
|
||||
@@ -39,10 +50,11 @@ else
|
||||
echo "** Script wird abgebrochen."
|
||||
echo "**"
|
||||
show_help
|
||||
exit 2
|
||||
exit 102
|
||||
fi
|
||||
|
||||
LOG_FILE="$NAS_ROOT/log/$LOG_FILE-$(date '+%Y-%m-%d_%H%M').log"
|
||||
log_file_name="$NAS_ROOT/log/$HOST_NAME-$(date '+%Y-%m-%d_%H%M')"
|
||||
LOG_FILE="${log_file_name}.log"
|
||||
|
||||
file=
|
||||
archive=
|
||||
@@ -54,15 +66,21 @@ while :; do
|
||||
exit 0
|
||||
;;
|
||||
-d|--daily)
|
||||
LOG_FILE=$BACKUP_TARGET/backup.log
|
||||
MAIL_LOG_FILE="${log_file_name}.auto.log"
|
||||
## copy_to_nas
|
||||
backup_daily
|
||||
break
|
||||
;;
|
||||
-w|--weekly)
|
||||
LOG_FILE=$BACKUP_TARGET/backup.log
|
||||
MAIL_LOG_FILE="${log_file_name}.auto.log"
|
||||
backup_weekly
|
||||
break
|
||||
;;
|
||||
-e|--export)
|
||||
MAIL_LOG_FILE="${log_file_name}.auto.log"
|
||||
export_backups
|
||||
break
|
||||
;;
|
||||
--list)
|
||||
list_archives "$NAS_ROOT/daily/$HOST_NAME"
|
||||
if [ -d "$NAS_ROOT/weekly/$HOST_NAME" ]; then
|
||||
@@ -88,22 +106,6 @@ while :; do
|
||||
fi
|
||||
break
|
||||
;;
|
||||
|
||||
# --- example -> https://mywiki.wooledge.org/BashFAQ/035
|
||||
-f|--file) # Takes an option argument; ensure it has been specified.
|
||||
if [ "$2" ]; then
|
||||
file=$2
|
||||
shift
|
||||
else
|
||||
die 'ERROR: "--file" requires a non-empty option argument.'
|
||||
fi
|
||||
;;
|
||||
--file=?*)
|
||||
file=${1#*=} # Delete everything up to "=" and assign the remainder.
|
||||
;;
|
||||
--file=) # Handle the case of an empty --file=
|
||||
die 'ERROR: "--file" requires a non-empty option argument.'
|
||||
;;
|
||||
--) # End of all options.
|
||||
shift
|
||||
break
|
||||
|
||||
Reference in new issue
Block a user