Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # save this as an application and put it in login items
- # Run this in Apple Script editor
- property userName : "<Username>"
- property diskName : "<DiskName>"
- property serverAddress : "smb://DiskName"
- property userPassword : "<Password>"
- on connectToServer()
- global userName
- global diskName
- global serverAddress
- global userPassword
- set mountedDisks to list disks
- if mountedDisks does not contain diskName then
- mount volume serverAddress as user name userName with password userPassword
- end if
- takeBackUp()
- set mountedDisks to list disks
- if mountedDisks contains diskName then
- end if
- end connectToServer
- on takeBackUp()
- set workspace to (path to desktop as text) --"Users:iosdev:Desktop"
- set {year:y, month:m, day:d} to (current date)
- set timeString to replace_chars(time string of (current date), ":", "-") as string
- set p to "-"
- set mydate to (d & p & m * 1 & p & y & p & timeString) as string
- set mydate to replace_chars(mydate, " ", "_") as string
- set filename to mydate as string
- tell application "Finder"
- set inputFolder to "Macintosh HD:Users:iosdev:AppFolder:"
- set filePath to "Macintosh HD:Users:iosdev:"
- tell current application
- set qpp to quoted form of POSIX path of inputFolder
- do shell script "cd $(dirname " & qpp & ")
- zip -r \"$(basename " & filename & ").zip\" \"$(basename " & qpp & ")\""
- set zipFile to filePath & filename & ".zip"
- end tell
- set destination to "PQA_APP_BackUp:"
- try
- move zipFile to destination
- delete zipFile
- on error
- display dialog ("Backup saved locally. Please move it to server.")
- end try
- end tell
- end takeBackUp
- on replace_chars(this_text, search_string, replacement_string)
- set AppleScript's text item delimiters to the search_string
- set the item_list to every text item of this_text
- set AppleScript's text item delimiters to the replacement_string
- set this_text to the item_list as string
- set AppleScript's text item delimiters to ""
- return this_text
- end replace_chars
- connectToServer()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement