1.Store a fixed file "exists.txt" on your hard drive; use a plugin, to check if the file exists (e.g. Troi File or BE plugin).
2.Include current time stamp into the name of the backup file to make it unique.
What is the script needed to include the time stamp in the backup file name?
Why check before saving the file? If the save fails, an error would be generated in either case, and in both cases they'd have to plug the drive in.
The bigger issue is that you're trying to get FMP to save a file that is currently open to save a copy of itself some place else. You in effect are trying to pull the rug out from under your feet. Depending on what other scripts may have been halted or windows open, you won't be able to get FMP to save a copy of an open file, and even if you could, it would probably not be a valid copy. You could create a second FMP db that would perform the backup once the "main" file is closed.
You're better off using a backup program that would be activated when they shut the computer down to save a copy of certain files on another drive. This really is an excellent reason for using FileMaker Server as it can back up active files properly to any valid location.
FMP can save a copy of a locally opened file (in fact it cannot save a file unless it's already got it opened) but the problem is relying on the backup script being run at file exit. If the file is explicitly closed using the Close command then yes the onLastWindowClose script gets triggered. However, if the user issues the Quit/Exit command then it does NOT get fired. The lights have gone out, the rug has been pulled out from under you. (I dont think a lot of people realise this.)
IMHO the best solution for backup is FM Server. (Yes, I know all the arguments about costs etc but it IS the best solution.) Second best might be to prompt to make the backup at the start of the user session, not the end. That way you know the process isn't in a race condition with the closing of the file.
Thanks Bruce for your suggestion. It's exactly what I was looking for!
I was not aware of the website, but I now have it bookmarked...Don