Skip to content

Commit

Permalink
ENH Try reverse lookup of IPs and include hostname/IP in filename
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhq committed Jan 27, 2015
1 parent 139e036 commit cf69f01
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion zabbix-mysql-backupconf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# HISTORY
# 0.7.1 (2015-01-27)
# NEW: Parsing of commandline arguments implemented
# ENH: Try reverse lookup of IPs and include hostname/IP in filename
# REV: Stop if database password is wrong
#
# 0.7.0 (2014-10-02)
Expand Down Expand Up @@ -108,7 +109,12 @@ fi
MYSQL_CONN="-h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME}"
MYSQL_BATCH="mysql --batch --silent $MYSQL_CONN"

DUMPFILEBASE="zabbix_$(date +%Y%m%d-%H%M).sql"
# Try resolving a given host ip
DBHOSTNAME="$DBHOST"
newHostname=$(dig +noall +answer -x $DBHOST | sed -r 's/((\S+)\s+)+([^\.]+)\..*/\3/')
test \! -z "$newHostname" && DBHOSTNAME="$newHostname"

DUMPFILEBASE="zabbix_${DBHOSTNAME}_$(date +%Y%m%d-%H%M).sql"
DUMPFILE="${DUMPDIR}/${DUMPFILEBASE}"

#
Expand Down

0 comments on commit cf69f01

Please sign in to comment.