Jump to content

Backup script help


kgasman
 Share

This topic is 5732 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I wrote a filemaker pro 7 database program for my wife's practice. I wanted to create backups of the database for each time she changed something. Ideally I would keep only the last 2 months of backups and delete the rest. Since you can only make a file "Database Copy.fp7" from within Filemaker pro 7, I thought I would write an Applescript that could be called from within filemaker. I would set filemaker pro to call a filemaker script at shut down that would first make a generic backup of the database "Database Copy.fp7" in a backup folder "clientbackups". Then the filemaker pro script would perform an applescript to rename the file with a date and timestamp. I would then have the applescript delete all the files in the backup folder that were older than 2 months. As another wrinkle since the database is used on a desktop and laptop computer that are synchronized I didn't want the Applescript to delete files created on the desktop when run on the Laptop and vis a versa. My solution was to have the Filemaker script determine if the database was being run on the desktop or the Laptop and run the Applescript designed for each computer. The major difference was that the Applescript would add "L-" before the database name if on the laptop or "D-" before the name if on the desktop.

The following is the filemaker script:

Save a Copy as [ "file:clientbackups/database Copy.fp7" ] [compacted copy (smaller)]

Pause/Resume Script [ Duration (seconds): 2]

If [ Get ( HostName ) = "Kevin desktop" ]

Perform AppleScript [ ]

Exit Script

End If

If [ Get ( HostName ) = "Kevin Laptop" ]

Perform AppieScript [ ]

Exit Script

End If

I am a novice at applescript but from searching Macscripter.com site I came up with the following is the Applescript for the laptop:

tell application "Finder"

set somedate to current date

set shortsomedate to short date string of somedate

set hrsomedate to hours of somedate as number

set minsomedate to minutes of somedate as number

set secsomedate to seconds of somedate as number

set the name of file "Macintosh HD:Users:AllynLaptop:Documents:Allyn Clients:clientbackups:ClientDatabase Copy.fp7" to "L-ClientDatabaseBKUP" & shortsomedate & " " & hrsomedate & "-" & minsomedate & "-" & secsomedate & ".fp7"

set thefolder to alias "/Users/AllynLaptop/Documents/Allyn Clients/clientbackups"

delete (items of thefolder whose creation date < ((current date) - (60 * days)) and name contains "L-")

end tell

for the Desktop I just substitute the desktop file path names and prepend "D-" to the backup file name.

I tested the filemaker script and had to add the pause script step or I got a applescript error that it couldn't find the backup file copy. Although the Applescript works fine when run as a stand alone applescript; when placed in the filemaker script I keep getting a out of memory error.

Do I need the applescript to tell filemaker to quit before I change the backup files name?

Any thoughts help or suggestions would be much appreciated

Kevin

Model: iMac G4 and ibook G4

AppleScript: 1.10.3

Operating System: Mac OS X (10.4)

Link to comment
Share on other sites

Have you considered hosting the file with FileMaker Server? This solve both of your problems (e.g. easy automated backups, and no need to synchronize the files, since it's only a single file)?

Link to comment
Share on other sites

Thanks for replying. I did consider it, but didn't want the expense and headache of upgrading from Filemaker Pro 7. I am sure I can accomplish this with applescript it just needs tweaking, I hope.

Link to comment
Share on other sites

I was able to get it to work by putting a Pause script step after the perform applescript step. I am sure someone out there can show me a more elegant applescript.

Thanks for any help

Link to comment
Share on other sites

This topic is 5732 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.