Ok so I'm done with Perl, it's just not my cup of tea. So I decided to just rewrite the script in Bash.
It works but I have 2 more complicated things I would like it to do, one I would like for it to rerun if the rsync fails and 2 I would like an output of the files I am deleting.
Code:
export_dir="/oracle/path"
remote_dir="/u04/path"
archive_dir="/oracle_exports/path"
date=`date +%Y%m%d`
dump="fullexp_$date.dmp"
cd $export_dir
if [ -f $dump ]; then
/bin/su - oracle -c "rsync -navz --progress $export_dir/$dump oracle@ipaddress:$remote_dir/" > $export_dir/db_rsync$date.log;
else
echo "$dump export does not exist"
fi
exit 0
find ${export_dir} -name '*.bz2' -mtime +31 -type f exec rm -rf {} \;
cd $archive_dir
find $(archive_dir} -name '*.bz2' -mtime +360 -type f exec rm -rf {} \;