I have writen this script and want to make sure this is the best way to back and sync a folder to the server. Any suggestions would be helpful.
tell application "System Events" to get name of current user
set iUser to result
set iVolume to "EMPLOYEE_BACKUP"
if (list disks) does not contain iVolume then
display dialog "Enter Network Password" default answer "" with hidden answer
set iPass to the text returned of the result
set iServer to "afp://ourserver/EMPLOYEE_BACKUP"
mount volume iServer as user name iUser with password iPass
do shell script "rsync -a -e ssh /My\\ Projects /Volumes/EMPLOYEE_BACKUP/`whoami`/My_Backup --update"
else
do shell script "rsync -a -e ssh /My\\ Projects /Volumes/EMPLOYEE_BACKUP/`whoami`/My_Backup --update"
end if
The “front” end certainly looks ok. Can’t test the rsync scripts, so don’t know about them.
You can compress things a bit here and there:
display dialog "Enter Network Password" default answer "" with hidden answer
set iPass to the text returned of the result
-- can become:
set iPass to text returned of (display dialog "Enter Network Password" default answer "" with hidden answer)
but that’s no big deal.
Also, this works - you don’t need an else since it’s the same either way:
if (list disks) does not contain iVolume then
display dialog "Enter Network Password" default answer "" with hidden answer
set iPass to the text returned of the result
set iServer to "afp://ourserver/EMPLOYEE_BACKUP"
mount volume iServer as user name iUser with password iPass
end if
do shell script "rsync -a -e ssh /My\\ Projects /Volumes/EMPLOYEE_BACKUP/`whoami`/My_Backup --update"