utils upgrade
This commit is contained in:
parent
ebcf3ac20b
commit
ccc45b06ea
@ -11,9 +11,10 @@ function usage {
|
||||
|
||||
echo Starting $0 $*
|
||||
|
||||
LogDir=${1}
|
||||
# ---- D e f a u l t s
|
||||
LogArchiveDir=/works/archive/logs
|
||||
DateCriteria="2 days ago"
|
||||
# ---- D e f a u l t s
|
||||
|
||||
|
||||
# ---------------- cmdline
|
||||
|
||||
@ -1,40 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# FOR cloud hosts with limited disk space - move to storage server
|
||||
# FOR hosts with limited disk space - move to storage server
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} <host> <from_dir> <days>"
|
||||
echo -n "Usage: ${0}"
|
||||
echo -n " -H <host_label>"
|
||||
echo -n " [ -A <archive_dir> (default /works/archive)]"
|
||||
echo -n " [-D <older than time criteria> (default: '2 days ago')]"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo Starting $0 $*
|
||||
|
||||
|
||||
# ---- D e f a u l t s
|
||||
ArchiveDir=/works/archive
|
||||
DateCriteria="2 days ago"
|
||||
FromHost=$(hostname -s)
|
||||
# ---- D e f a u l t s
|
||||
|
||||
# ---------------- cmdline
|
||||
while getopts "A:H:D:" opt; do
|
||||
case ${opt} in
|
||||
A )
|
||||
ArchiveDir=$OPTARG
|
||||
;;
|
||||
H )
|
||||
FromHost=$OPTARG
|
||||
;;
|
||||
D )
|
||||
DateCriteria=$OPTARG
|
||||
;;
|
||||
\? )
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
: )
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# ---------------- cmdline
|
||||
|
||||
|
||||
if [ "${FromHost}" == "" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
ArchiveDir=${2}
|
||||
if [ "${ArchiveDir}" == "" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
Days=${3}
|
||||
if [ "${Days}" == "" ]
|
||||
then
|
||||
Days=2
|
||||
fi
|
||||
|
||||
DateCriteria="${Days} days ago"
|
||||
|
||||
TargetHost=cloud21.cvtt.vpn
|
||||
TargetRootDir=/opt/store/cvtt/archive
|
||||
|
||||
Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d')
|
||||
Now=$(date '+%Y%m%d_%H%M%S')
|
||||
Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
echo "Looking for log files older than ${DateCriteria} in ${ArchiveDir}"
|
||||
Cmd="find ${ArchiveDir}/"
|
||||
@ -45,7 +62,7 @@ Cmd="${Cmd} -o -name '*.logs.*'"
|
||||
Cmd="${Cmd} -o -name '*.tgz'"
|
||||
Cmd="${Cmd} ')'"
|
||||
Cmd="${Cmd} -type f"
|
||||
Cmd="${Cmd} -not -newermt ${Oldest}"
|
||||
Cmd="${Cmd} -not -newermt \"${Oldest}\""
|
||||
|
||||
echo ${Cmd}
|
||||
files=$(eval ${Cmd})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user