Advertisement
Guest User

Untitled

a guest
Jan 20th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. # save this as an application and put it in login items
  2. # Run this in Apple Script editor
  3.  
  4. property userName : "<Username>"
  5. property diskName : "<DiskName>"
  6. property serverAddress : "smb://DiskName"
  7. property userPassword : "<Password>"
  8.  
  9. on connectToServer()
  10. global userName
  11. global diskName
  12. global serverAddress
  13. global userPassword
  14.  
  15. set mountedDisks to list disks
  16. if mountedDisks does not contain diskName then
  17. mount volume serverAddress as user name userName with password userPassword
  18. end if
  19. takeBackUp()
  20.  
  21. set mountedDisks to list disks
  22. if mountedDisks contains diskName then
  23. end if
  24. end connectToServer
  25.  
  26.  
  27. on takeBackUp()
  28. set workspace to (path to desktop as text) --"Users:iosdev:Desktop"
  29. set {year:y, month:m, day:d} to (current date)
  30. set timeString to replace_chars(time string of (current date), ":", "-") as string
  31. set p to "-"
  32. set mydate to (d & p & m * 1 & p & y & p & timeString) as string
  33. set mydate to replace_chars(mydate, " ", "_") as string
  34. set filename to mydate as string
  35.  
  36. tell application "Finder"
  37.  
  38. set inputFolder to "Macintosh HD:Users:iosdev:AppFolder:"
  39. set filePath to "Macintosh HD:Users:iosdev:"
  40. tell current application
  41.  
  42. set qpp to quoted form of POSIX path of inputFolder
  43. do shell script "cd $(dirname " & qpp & ")
  44. zip -r \"$(basename " & filename & ").zip\" \"$(basename " & qpp & ")\""
  45. set zipFile to filePath & filename & ".zip"
  46. end tell
  47.  
  48. set destination to "PQA_APP_BackUp:"
  49.  
  50. try
  51. move zipFile to destination
  52. delete zipFile
  53. on error
  54. display dialog ("Backup saved locally. Please move it to server.")
  55.  
  56. end try
  57. end tell
  58. end takeBackUp
  59.  
  60. on replace_chars(this_text, search_string, replacement_string)
  61. set AppleScript's text item delimiters to the search_string
  62. set the item_list to every text item of this_text
  63. set AppleScript's text item delimiters to the replacement_string
  64. set this_text to the item_list as string
  65. set AppleScript's text item delimiters to ""
  66. return this_text
  67. end replace_chars
  68. connectToServer()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement