Advertisement
Guest User

Untitled

a guest
Mar 31st, 2011
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.91 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. dummy_s=
  4. mail_list="user@gmail.com"
  5.  
  6. a=$@
  7.  
  8. #Get interval
  9. int=`echo $a | awk '{ print $NF }'`
  10.  
  11. #Remove interval from arguments
  12. aa=`echo $a | sed '$s/ *\([^ ]* *\)$//'`
  13. #Get config name with fake interval
  14. config=`rsnapshot  -v $aa kjszdghm34w 2>&1 | awk '/ERROR/ {print $6}'`
  15.  
  16. #Get snapshot root
  17. sroot=`cat $config | awk '$1 ~ /snapshot_root/ {print $2}'`
  18. co=$sroot/control
  19. #touch "$co"
  20.  
  21. cleanup_old() {
  22.         $dummy_s mv "$sroot"/"$int".0 "$sroot"/"$int".0.failed
  23.         $dummy_s rm "$co"
  24. }
  25.  
  26. send_notification() {
  27. (echo ERROR: Control file exists. Previous backup has not completed; \
  28. ls -l $co) \
  29. | mailx -s "Rsnapshot has failed on `hostname`" $mail_list
  30. }
  31.  
  32. if [ -f "$co" ]; then
  33. echo ERROR: Control file exists. Previous backup has not completed
  34. send_notification
  35. cleanup_old
  36. fi
  37.  
  38. $dummy_s touch "$co"
  39. $dummy_s rsnapshot  $@
  40. $dummy_s rm "$co"; logger backup completed $config
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement