Tuesday, November 21, 2017

apple script to create iOS backup on external drive

--> Created by Deepak Lohia email at deepak9delhi@gmail.com for Only business queries. 
--> visit http://www.freevbatips.com for more 

set theOutputFolder to choose folder with prompt "Select the External folder for Backup !"
set theOutputFolder to POSIX path of theOutputFolder

set the ExFolder to findAndReplaceInText(theOutputFolder, " ", "\\ ")
on findAndReplaceInText(theText, theSearchString, theReplacementString)
set AppleScript's text item delimiters to theSearchString
set theTextItems to every text item of theText
set AppleScript's text item delimiters to theReplacementString
set theText to theTextItems as string
set AppleScript's text item delimiters to ""
return theText
end findAndReplaceInText

set msg to "Error"
tell application "Finder"
set displayappath to ("~/Library/Application\\ Support/MobileSync/Backup2" as text)
if exists displayappath then
set msg to displayappath & " Exists - Oops , seems like you have already ran the script."
display dialog msg
quit
end if
end tell

--display dialog "Folder will be created on " & theOutputFolder & "Backup"
--display dialog theOutputFolder

tell application "Terminal"
activate
if not (exists window 1) then reopen
set window_id to id of first window whose frontmost is true
--> CREATING FOLDER IN EXTERNAL DRIVE FOR BACKUP
do script ("mkdir -p " & ExFolder & "Backup") in window id window_id of application "Terminal"
--> RENAMING EXISTING BACKUP FODLER TO BACKUP2
do script ("mv ~/Library/Application\\ Support/MobileSync/Backup ~/Library/Application\\ Support/MobileSync/Backup2") in window id window_id of application "Terminal"
--> CREATING SYMBOLIC LINK TO THE EXTERNAL DRIVE FOLDER
do script ("ln -s " & ExFolder & "Backup ~/Library/Application\\ Support/MobileSync/") in window id window_id of application "Terminal"
display dialog "Folder created on " & theOutputFolder & "Backup - for iOS Backup"
end tell




3 comments:

  1. Hi Deepak,

    Thank you for you very easy to follow script, yet I made somewhere wrong.
    it says timed out ... I have the screeenshot ... how should I share it.

    exact dialog box:
    SCRIPT ERROR
    "TERMINAL GOT AN ERROR: APPLE EVENT TIMED OUT"

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. i know i am too late to reply , because i dont check comments here.
    the issue could be because of admin access , you have to ensure that password is correct and try closing the window and re logging in.

    In case your issue is still pending. you can comment on my Youtube page , as i dont monitor these comments.

    Good luck :)

    ReplyDelete

Note: Only a member of this blog may post a comment.