Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tell application "Console"
- activate
- ---set the BackupLog filename info
- set {year:y, month:m, day:d, hours:h, minutes:min, seconds:sec} to (current date)
- end tell
- log "Starting Script"
- --set the variables
- set studio to "STUDIONAME"
- set userName to short user name of (system info)
- set newFileName to "BackupLog" & "_" & userName & "--" & d & ":" & (m as integer) & ":" & y & "--" & h & "h" & min & ".log"
- set rsync_error_flag to false -- set a boolean flag to test for error condition
- set backup_error_flag to false -- set a boolean error flag for backup move to false
- delay 2
- do shell script "logger *** STARTING BACKUP SCRIPT for " & studio
- tell application "Finder"
- set mounted_Disks to list disks
- if mounted_Disks contains "SERVER SHARE" then
- eject "SERVER SHARE"
- delay 10
- do shell script "mount -t afp afp://SERVER SHARE LOCATION"
- delay 10
- else if mounted_Disks does not contain "SERVER SHARE" then
- do shell script "logger Mounting SERVER SHARE"
- do shell script "mount -t afp afp://SERVER SHARE LOCATION"
- delay 10
- end if
- do shell script "logger SERVER SHARE mounted"
- delay 3
- do shell script "logger Backup Script Starting"
- try -- start of the try catch block
- do shell script "$HOME/mnt/scripts/" & studio & "_BackupV5.sh // &> $HOME/mnt/Logs/" & newFileName -- calls rsync shell script, this is the script that can produce an error
- on error error_string number error_number -- if we catch an error set the returned error to error_string & error_number variables
- set rsync_error_flag to true -- if we catch error set the flag to true
- end try -- end of the try catch block
- do shell script "logger -f $HOME/mnt/Logs/" & newFileName -- writes the log file
- end tell
- tell application "Finder"
- eject "SERVER SHARE"
- delay 10
- end tell
- tell current application
- activate
- if rsync_error_flag then -- if flag is true then display a dialogue showing errors
- display dialog "Backup Script Failed...
- " & (error_string) & "
- Error code : " & (error_number) & "
- Check Backup Logs for More Info" buttons {"Cancel", "OpenLog"} default button 2
- if the button returned of the result is "Cancel" then
- cancel -- action for 1st button goes here
- else
- do shell script "open $HOME/mnt/Logs" -- action for 2nd button goes here
- end if
- end if
- if rsync_error_flag is false then -- rsync completed ok so now we move data to Backup folder
- try
- do shell script "logger - Starting Backup Move Operation ADD HOUSEKEEPING"
- on error error_string number error_number
- set backup_error_flag to true -- if error moving folder then set flag to true
- end try
- if backup_error_flag then
- display dialog "Backup Move Failed...
- " & (error_string) & "
- Error code : " & (error_number)
- else -- if backup error flag is false do this
- display dialog "Backup Script Complete"
- end if
- --else -- if backup error flag is false do this
- -- display dialog "Backup Script Complete"
- end if
- end tell
- tell application "Console"
- quit
- end tell
Add Comment
Please, Sign In to add comment