Example backup script
You can use the following script to save automated backup copies of a FileMaker Pro database.
This script saves a copy of your database on the fifth close and every fifth close thereafter. To make the script work, you need to define a global field called Count Field in one of the tables in your database. If you do not define a global number field, FileMaker Pro may increment a different record each time you close the application. You should define this script in all custom app files that require backups.
To create the script:
- Choose Scripts menu > Script Workspace. Or, choose File menu > Manage > Scripts.
- In the Script Workspace, click .
For details on creating scripts, see Creating and editing scripts.
- Name the script
Backup, then press Enter.
- Enter the following script steps:Copy
Set Field [<table name>::Count Field; <table name>::Count Field + 1]
If [<table name>::Count Field > 4]
Save a Copy as ["Backup Copy.fmp12"; copy of current file ; Create folders: Off]
Set Field [<table name>::Count Field; 0]
- When you are finished, close the tab in the script editing pane, then click Save.
- Close the Script Workspace.
- Choose File menu > File Options, and click the Script Triggers tab.
- Click the OnLastWindowClose script trigger, then click Select.
- Select the Backup script.
- Click OK.
- Close the file.
This script will create a backup of your file every fifth time you close the file.