diff --git a/move_archives.sh b/move_archives.sh index 163fbbf..73e61d4 100755 --- a/move_archives.sh +++ b/move_archives.sh @@ -52,7 +52,7 @@ echo "Looking for log files older than ${DateCriteria} in ${ArchiveDir}" # 1. First, check if any matching files exist using a quick find check -if ! find "${ArchiveDir}" -type f -not -newermt "${Oldest}" -print -quit | grep -q .; then +if ! find "${ArchiveDir}/" -type f -not -newermt "${Oldest}" -print -quit | grep -q .; then echo "No files found older than ${Oldest} in ${ArchiveDir}" echo "Done ${0} ${*}" exit 0 @@ -65,8 +65,9 @@ echo "-----------------" # 2. Safely pipe find into rsync using relative paths from the ArchiveDir base # This completely avoids "Argument list too long" errors and handles spaces perfectly set -x -find "${ArchiveDir}" -type f -not -newermt "${Oldest}" -printf "%P\0" | \ +find "${ArchiveDir}/" -type f -not -newermt "${Oldest}" -printf "%P\0" | \ rsync -ahvv \ + -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \ --remove-source-files \ --mkpath \ --from0 \