#!/bin/bash function usage { echo "Usage: ${0} [ (default: cloud11)]" exit 1 } FromHost=${1} if [ "${FromHost}" == "" ] then FromHost=cloud11 fi echo Starting $0 $* ArchiveDir=/home/cvtt/prod/archive Target=cloudstore.cvtt.vpn:/home/cvtt/Archive/${FromHost}/ # DateCriteria="week ago" DateCriteria="2 days ago" Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d') Now=$(date '+%Y%m%d_%H%M%S') echo "Looking for log files older than ${DateCriteria} in ${ArchiveDir}" Cmd="find ${ArchiveDir}/" Cmd="${Cmd} '('" Cmd="${Cmd} -name '*.log'" Cmd="${Cmd} -o -name '*.log.*'" Cmd="${Cmd} -o -name '*.logs.*'" Cmd="${Cmd} -o -name '*.tgz'" Cmd="${Cmd} ')'" Cmd="${Cmd} -type f" Cmd="${Cmd} -not -newermt ${Oldest}" echo ${Cmd} files=$(eval ${Cmd}) if [ "$files" == "" ] then echo "No files found older than ${Oldest} in ${LogDir}" else echo Archiving files: echo ----------------- for f in ${files} do echo ${f} done Cmd="rsync -ahvv" Cmd="${Cmd} --remove-source-files" Cmd="${Cmd} $files" Cmd="${Cmd} ${Target}" echo ${Cmd} # exit eval ${Cmd} fi echo Done ${0} ${*}