Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

I thought I might as well share this, as it's taken me a while to figure this out.

We needed a script to automatically connect to our FM host's FTP server, and download that day's backup. This shell script here does that, plus compresses and renames the resulting .tar file to date. This will run on any Unix system; we use it on a computer in our office running Mac OS X.


#!/bin/sh



##############################################################################

# script that downloads a file, compresses and renames it to date

# copy to plain text editor and  save as  fmbackup.sh

# open Terminal, run "chmod +x fmbackup.sh" (drag sh file into terminal after 'hmod +x')

# press return





# set desired backup location. manually create this folder if it doesn't exist.

cd "/Users/Shared/FMbackup/"



#holding off 5 seconds at the beginning to give time to establish network connection

echo "starting in 5 seconds"

sleep 5



echo "downloading latest backup of Filemaker database"



#dates in folder path are in this format: 2010-10-14; must be set as variable

DATE=`date '+%Y-%m-%d'`



curl --ftp-ssl --remote-time  ftp://username:[email protected]/backup_${DATE}_2040/Databases/path/to/file/Database.fp7 -o "Database_backup.fp7"



# compress and rename to date

tar cvfpz "Database `date '+%d-%B-%Y'`."tar "Database_backup.fp7"





# FM Server v.11 now puts its automatic backups in folders renamed to the current date. This script must be run on same day or evening as it uses the current date in the download URL.

# can be made a standalone app on MAC OS X using 'Platypus' (3rd party util)

# to automate, create a recurring event in iCal



Posted

Very funny. No, what I'm not wondering what its name is. I'm wondering what makes the script run, or how you automate the task?

Posted

Sorry. Well, on OS X the easiest way is to create a recurring event in iCal, and as 'alarm' choose 'Open File'. I found it's best to make the script a standalone application first; I did that with Platypus, a third-party app that lets you do just that with any kind of scripts.

Platypus gives you all kinds of options, like to automatically quit afterwards, or to run on the background.

Surely there are other ways to call the script, e.g. cron if it's a Linux server. On newer versions of OS X, cron has been replaced by launchd, which I found too difficult to handle.

By the way, everything with a # in front is a comment; just in case if you need to adjust anything to your needs.

Posted

You can also call shell scripts from AppleScript. This way you can incorporate the feature into a Filemaker solution pretty seamlessly. I believe you could do the same thing on Windows, except you would need a plugin to get a response.

Posted

On newer versions of OS X, cron has been replaced by launchd, which I found too difficult to handle.

I still use crontab on Snow Leopard. The OS may not use cron anymore they haven't removed the old Unix functions.

×
×
  • Create New...

Important Information

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