From 59eb06fd58afc1226840c40f521d0f3810869b79 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Sun, 6 Aug 2023 21:57:49 +0000 Subject: [PATCH] progress --- release_version.txt | 2 +- utils/move_archives.sh | 59 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 utils/move_archives.sh diff --git a/release_version.txt b/release_version.txt index 1180819..699c6c6 100644 --- a/release_version.txt +++ b/release_version.txt @@ -1 +1 @@ -0.1.7 +0.1.8 diff --git a/utils/move_archives.sh b/utils/move_archives.sh new file mode 100755 index 0000000..ce61c8c --- /dev/null +++ b/utils/move_archives.sh @@ -0,0 +1,59 @@ +#!/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} ${*}