Advertisement
talran

Untitled

Jan 25th, 2017
113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/ksh
  2.  
  3. HOSTS="svr1 svr2 svr3 svr4 svr5"
  4. DATE=`date '+%m%d%y.%H%M'`
  5. LOG=/usr/local/scripts/xfer_failed
  6.  
  7. export HOSTS DATE LOG
  8.  
  9. ### Main ###
  10.  
  11. if [ -f $LOG ];
  12. then mv $LOG $LOG.$DATE
  13. touch $LOG
  14. else touch $LOG
  15. fi
  16. #
  17. for each in $HOSTS;
  18. do
  19. if [ ! -d /usr/restore/$each ];
  20. then mkdir /usr/restore/$each
  21. fi
  22. cd /usr/restore/$each
  23. find . -type f -name "$each*.tar*" -mtime +14 -exec rm {} \;
  24. #
  25. sftp -b - $each << EOF
  26. get /root/restore/$each.tar $each.$DATE.tar
  27. bye
  28. EOF
  29. if [ $? -ne 0 ];
  30. then echo "File transfer for $each failed. $DATE" >> $LOG
  31. cat $LOG | mailx -s "Vitalfile transfer failure" xxxxxxx@xxxxxx.com
  32. else continue
  33. fi
  34. done
  35.  
  36. find /usr/local/scripts -type f -name "xfer_failed.*" -mtime +4 -exec rm {} \;
  37.  
  38. ### End Main ###
Advertisement
RAW Paste Data Copied
Advertisement