added hostname to archive files
This commit is contained in:
+11
-3
@@ -16,9 +16,10 @@ LogDir=${1}
|
|||||||
LogArchiveDir=/works/archive/logs
|
LogArchiveDir=/works/archive/logs
|
||||||
DateCriteria="2 days ago"
|
DateCriteria="2 days ago"
|
||||||
ExtraWildCard=
|
ExtraWildCard=
|
||||||
|
AddHostname=
|
||||||
|
|
||||||
# ---------------- cmdline
|
# ---------------- cmdline
|
||||||
while getopts "A:L:D:W:" opt; do
|
while getopts "A:L:D:W:H" opt; do
|
||||||
case ${opt} in
|
case ${opt} in
|
||||||
A )
|
A )
|
||||||
LogArchiveDir=$OPTARG
|
LogArchiveDir=$OPTARG
|
||||||
@@ -32,6 +33,9 @@ while getopts "A:L:D:W:" opt; do
|
|||||||
W )
|
W )
|
||||||
ExtraWildCard=$OPTARG
|
ExtraWildCard=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
H )
|
||||||
|
AddHostname=Y
|
||||||
|
;;
|
||||||
\? )
|
\? )
|
||||||
echo "Invalid option: -$OPTARG" >&2
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
usage
|
usage
|
||||||
@@ -74,7 +78,11 @@ if [ "$files" == "" ]
|
|||||||
then
|
then
|
||||||
echo "No files found older than ${Oldest} in ${LogDir}"
|
echo "No files found older than ${Oldest} in ${LogDir}"
|
||||||
else
|
else
|
||||||
echo Archiving files:
|
TarFile="${LogArchiveDir}/${tmsig}.logs.tgz"
|
||||||
|
if [ "${AddHostname}" == "Y" ] ; then
|
||||||
|
TarFile="${LogArchiveDir}/${tmsig}.$(hostname -s).logs.tgz"
|
||||||
|
fi
|
||||||
|
echo Archiving to ${TarFile} files:
|
||||||
echo -----------------
|
echo -----------------
|
||||||
echo ${files}
|
echo ${files}
|
||||||
|
|
||||||
@@ -86,7 +94,7 @@ else
|
|||||||
tmsig="$(date -d "${tstmp1}" +"%Y%m%d_%H%M%S")-$(date -d "${tstmp2}" +"%Y%m%d_%H%M%S")"
|
tmsig="$(date -d "${tstmp1}" +"%Y%m%d_%H%M%S")-$(date -d "${tstmp2}" +"%Y%m%d_%H%M%S")"
|
||||||
echo $tmsig
|
echo $tmsig
|
||||||
|
|
||||||
Cmd="tar zcvf ${LogArchiveDir}/${tmsig}.logs.tgz ${files}"
|
Cmd="tar zcvf ${TarFile} ${files}"
|
||||||
echo $Cmd
|
echo $Cmd
|
||||||
eval $Cmd
|
eval $Cmd
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user