Backup FileMaker 17 Databases to the Cloud


FileMaker 17 introduces a useful new feature called “Create Directories” when creating files. This works with saving a copy or clone of the database, as well as exporting PDFs or text files. I decided this was a good time to update my old Backup database script. 

I use this script when developing locally. If I am about to make a major change to a layout etc, I can invoke this to give me a date and timestamped version of the database. This script could also be useful when developing for people who are using the database in a stand alone environment (ie. not on FileMaker Server), running it with FileMaker Pro client. Because you don’t know much about the client’s environment, such as where they want to backup to or the folder they want to backup to, it is useful to have a general purpose script like this. 

The only thing that took a bit of work was figuring out where iCloud Drive stores it’s files. See below for the solution.

Download: FileMaker 17 Backup Database Demo

HB-Backup Database 17

hb-backup-database-17

Backup to Cloud Services 

backup-to-cloud-services-

Select a location to backup to. In addition to local storage (Desktop and Documents), I have tested this on both iCloud and Google Drive. You could add others to the list, such as Box etc. Any service that gives you a local folder to sync to, could work. Your mileage may vary, please test first.

Backup Now Script

backup-now-script

This is the bread and butter script. It basically sets the file name, the directory and the folder name to build a path for the file. Then a Custom Dialog box comes up offering the user the option of saving now. Finally the file gets saved to the defined folder.

Date and Timestamp the File Name

date-and-timestamp-the-file-name

This routine pads the date and time numbers with zeros to the left.

Let(

[now = Get ( CurrentTimestamp ) ;

year = Year ( now ) ;

month = Right ( “0” & Month ( now ) ; 2 ) ;

day = Right ( “0” & Day ( now ) ; 2 ) ;

hour = Right ( “0” & Hour ( now ) ; 2 ) ;

mins = Right ( “0” & Minute ( now ) ; 2 ) ;

secs = Right ( “0” & Seconds ( now ) ; 2 )

] ;

year &”-“& month &”-“& day & “_” & hour &”-“& mins &”-“& Get ( FileName  )

)&”.fmp12″

Special Case for iCloud Drive

special-case-for-icloud-drive

If ( Globals::Backup Location= “iCloud”; Substitute ( Get(DesktopPath) ; “Desktop” ; “Library/Mobile Documents/com~apple~CloudDocs” ); 

Substitute ( Get(DesktopPath) ; “Desktop” ; Globals::Backup Location ))

I am using the Get DesktopPath function to get a basic path statement and then swapping out the word “Desktop” for “Documents”, or “Google Drive” etc. The only odd case is iCloud Drive which uses an unusual path. 

NEW to FM 17: Turn ‘Create Directories’ ‘On’

new-to-fm-17--turn--create-directories---on-

This is the new FM 17 features called Create Directories. If the folder doesn’t exist, you don’t get an error message, FileMaker just creates the directory. It only took 17 versions to get this!

Saved File

saved-file

File successfully saved to iCloud Drive, in the desired folder with a date and time stamp prefix.

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: