periodically backing up to idisk

I want to back up a file to my idisk folder periodically. The following code is a beginning:

tell application “Finder”

 mount volume "afp://" 
  duplicate "Macintosh HD:filename" to "IDiskusername:Public" with replacing 

end tell

The first problem with this script is that every time it runs, another image of my idisk appears on the desktop-how do i keep from mounting the idisk if it’s already mounted? (idisk dismounts automatically if you dont access it for 5 minutes)

Secondly, when the idisk is mounted by the above code, it’s write protected and the ‘backup’ folder is invisible. Why does it not mount with full access like when ‘idisk’ is selected from the ‘Go’ menu?



Something like this might work although, depending on the amount of security/privacy desired, I submit that storing passwords in scripts isn’t the best habit to get into.

set username to "iDiskUserName"
set pwd to "iDiskPassword"
set file_ to "path:to:file"

	tell application "Finder" to disk username
	-- if it makes it this far, a disk named username was detected.
on error
	-- a disk named username wasn't found so let's try to mount the iDisk.
		mount volume ("afp://" & username & ":" & pwd & "" & username)
	on error mountError
		display dialog mountError
		return -- terminate execution of the rest of the script
	end try
end try

tell application "Finder"
		duplicate alias file_ to folder "Public" of disk username with replacing
	on error dupeError
		display dialog dupeError
	end try
end tell

I can’t offer feedback regarding iDisk permissions/access.

– Rob

thanks. the only thing i added was

repeat while not (exists disk “username”)
end repeat

because idisk is slow to moount and the copy operation would give errors since idisk wasnt there yet.