Advertisement
applehelpwriter

postRun.sh

Dec 12th, 2016
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.33 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. ###########################################################
  4. # ABOUT
  5. ###########################################################
  6.  
  7. # Phil Stokes -- 2016
  8. # applehelpwriter.com
  9. # sqwarq.com
  10.  
  11.  
  12. ###################################################
  13. # DESCRIPTION
  14. ###################################################
  15.  
  16. # This script is for use with Carbon Copy Cloner.
  17. # It writes the date of the last successful backup to the destination disk.
  18. # This date can then be retrieved by a custom applescript[1] to check the last successful backupdate on the clone.
  19.  
  20. # [1] go to https://sqwarq.com/disk-inspector or applehelpwriter.com and search for "Disk Inspector"
  21. #
  22.  
  23. ###################################################
  24. # Variables
  25. ###################################################
  26.  
  27.  
  28. dest="$2"
  29. exitStatus="$3"
  30. writepath="$dest"/"lastLog.txt"
  31. dir="$dest"/"Users/Shared"
  32.  
  33.  
  34. ###################################################
  35. # COMMANDS
  36. ###################################################
  37. if [ "$1" = "/" ]; then
  38.     src=$(osascript -e 'tell application "System Events" to name of startup disk')
  39. else
  40.     src="$1"
  41. fi
  42.  
  43. if [ "$exitStatus" = "0" ]; then
  44.  
  45.     if [ -d "$dir" ]; then
  46.         writepath="$dir"/"lastLog.txt"
  47.     fi 
  48.     printf "$(date '+%A, %d %B %Y at %H:%M:%S')\n" > "$writepath"
  49.     printf "$src" >> "$writepath"
  50. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement