I want to copy data nightly from NAS1 to NAS2. I have the script below on NAS1 to use rsync to complete the copy but it is failing (I believe to an ssh issue that is explained move below).
Script #! /bin/sh
set -x #turn on echo to see commands
throwMessage() { TYPE=$ 2 if [ -z "$ TYPE" ]; then TYPE="Error" fi
echo "$ 1" | /usr/bin/mailx -s "nas2: $ TYPE rsyncing from nas1 to nas2!" development@goodlooking.company if ["$ TYPE" = "Error"]; then exit 1 else return 0 fi
}
LOG="/mnt/raidmount/logs/nas1.log" LOG_EXISTS="1" if [ ! -f $ LOG ]; then LOG_EXISTS="0" fi
exec > $ LOG 2>&1 set -x
echo "NAS1 backup started!" >> $ LOG
SOURCE="htadmin@10.0.0.210:/mnt/" TARGET="/mnt/raidmount/nas/"
rsync -rtlPDO –exclude ‘logs’ –exclude ‘*.bash_history’ $ {SOURCE} $ {TARGET} –delete
if [ "$ ?" != "0" ]; then
throwMessage "An error occurred while rsyncing from NAS1 to NAS2."
throwMessage "Error "$ ?" occurred while rsyncing from NAS1 to NAS2."
else if [ $ LOG_EXISTS = "0" ]; then rm $ LOG throwMessage "RSync from NAS1 to NAS2" "Success" else throwMessage "Log file existed prior to script run. remove /mnt/raidmount/logs/nas1.log" fi fi
Cron
RUN NAS BACKUPS EVERY DAY AT 00:00
0 0 * * 0,1,2,3,4,5,6 /home/htadmin/nasbak/nas1.sh >/dev/null 2>&1
Error in my log file
- rsync -rtlPDO –exclude logs –exclude *.bash_history htadmin@10.0.0.210:/mnt/ /mnt/raidmount/nas/ –delete Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,password).
Thoughts?
(forgive the formatting)