Title: Revised backup script
Sent this message a few days ago from the wrong account, and just noticed it bounced.  It addresses some of the problems raised on the list, but I haven’t incorporated any code to handle aliases in the Documents folder.

Someone mentioned documentation; I’ve been much more fully documenting this in my ASC uploads.  Of course, they never seem to show up in the indexes, so God only knows if anyone’s been finding them.

-----

Totally rewrote the backup script I posted the other day to fix a bug in the logic, and incorporate the criticism I heard.  Since the first script was buggy, I'm posting the script again; you can also download from AppleScriptCentral.

Best,
Jeff Porten

tell application "Finder"
    activate
    
    set NewBackupNeeded to false
    set OriginalFolder to folder "Documents:Microsoft User Data" of startup disk
    
    --
Does a backup exist?
   set FirstBackupExists to (exists folder "Documents:Microsoft User Data backup" of startup disk)
    
    if FirstBackupExists then
       --
Is a backup needed?
       set FirstBackupFolder to folder "Documents:Microsoft User Data backup" of startup disk
        set NewBackupNeeded to (modification date of FirstBackupFolder < (current date) - 1 * days)
    end if
   
    --
Does a second backup exist?
   set SecondBackupExists to (exists folder "Documents:Microsoft User Data old backup" of startup disk)
    
    if SecondBackupExists then
       set SecondBackupFolder to folder "Documents:Microsoft User Data old backup" of startup disk
    end if
   
    --
Is Entourage running?
   set EntActive to (exists process "Microsoft Entourage")
    
    --
Run the backup?
   set DoBackup to (NewBackupNeeded or (not FirstBackupExists))
    
    --
Enough disk space?
   set DataSize to size of OriginalFolder
    set AvailSpace to free space of startup disk
    if DataSize > AvailSpace then
       display dialog "There is not enough disk space to make a backup." buttons {"OK"} default button {"OK"} with icon stop
        set DoBackup to false
    end if
   
    if DoBackup then
       if EntActive then
           set QuitEnt to display dialog "You are currently running Entourage.  OK to quit?" buttons {"Don't quit, postpone backup", "Quit and backup"} default button 2 with icon caution
            if button returned of QuitEnt is "Quit and backup" then
               tell application "Microsoft Entourage" to quit
            else
               set DoBackup to false
            end if
       end if
   end if
   
    if DoBackup then
       if SecondBackupExists then
           move SecondBackupFolder to trash
        end if
       
        if FirstBackupExists then
           set the name of FirstBackupFolder to "Microsoft User Data old backup"
        end if
       
        set NewBackup to make new folder at folder "Documents" of startup disk with properties {name:"Microsoft User Data backup"}
        duplicate every item in OriginalFolder to NewBackup
    end if
   
    if EntActive and not (exists process "Microsoft Entourage") then
       tell "Microsoft Entourage"
            run
        end tell
   end if
   
end tell

Reply via email to