The following script will save a copy of the current file while appending the date to the end of the file name:
Set Variable [$Path ; Let ( today = Get ( CurrentDate ) ; "filewin:" & "/Put directory path here/" & Get ( FileName ) & " " & Year(today) & "-" & Right("00" & Month ( today ) ; 2 ) & "-" & Right("00" & Day ( Today ) ; 2 ) ) & ".FP7"]
Save a copy as ["$Path" ; Copy]
The challenge is to perform this script on a daily basis.
If [ get ( UserCount ) = 1]
at the beginning of this script and set the script to run every time the file is closed. When the file is closed on the host computer (Only time user count will be 1), the file is backed up across the network to a shared directory of nightly back ups. The host file must be closed each night or this back up will not take place.
A fileMaker "robot" file could be used with a system task scheduler to perform this script once a day at a specified time. In windows you'd use Windows Task Manager to "run" the robot file. The robot file has a script set to run when the file is opened that performs the back up script in the file you want to be backed up.
You don't want to use back up software to make back up copies of FileMaker files that are open. The backup copies could easily be corrupted and some FileMaker techs here have warned that even the original file could be damaged if it is open when the backup software kicks in. A backup file created by a server backup schedule or the above script is closed and thus backup software can back it up safely.
Thank you very much for your suggestions. I'm sorry, I haven't had much experience using scripts so some of the following questions may be a bit basic.
So, when i'm setting the script to run the backup, I select 'Set Variable' and then input [$Path ; Let ( today = Get ( CurrentDate ) ; "filewin:" & "/Put directory path here/" & Get ( FileName ) & " " & Year(today) & "-" & Right("00" & Month ( today ) ; 2 ) & "-" & Right("00" & Day ( Today ) ; 2 ) ) & ".FP7"]
I notice the end of the script is 'FP7.' Does this relate to the version of Filmaker?
Where it says "put directory path here" do I input where I want the backup copy to be saved?
Do I then select 'Save a copy as' and input the ("$Path";Copy)?
So the backup would start when the number of users was 1? Would shutting the files on the host computer not also shut the files on the other shared network computer making users 0? If not, it's ok for the other computer to have the Filemaker files open when the backup begins?
Thanks again for your help and patience!
.FP7 is the file extension for all FileMaker files produced by version FileMaker 7 through 11. The file format hasn't changed for all those versions so FileMaker Inc. has wisely kept the same file extension.
'Put directory path here' would need to be replaced by the path to your backup location. Typically, you start with either a volume name or drive letter followed by a list of directory names separated by /.
When you ad Save a copy as to your script, you'll find that you have a button towards the bottom labeled "Specify" click it and type in the name of your variable without any quotes. Then select "Copy" from the drop down just below this specify button.
Get ( USerCount ) counts the number of people connected to the file--including the host computer. If you have the file open on the host and then one user connects to it via Open Remote, this funciton returns 2 and the file will not be backed up when the user closes their session with the file. When you try to close the file while others are connected, you get a dialog message telling you that others are logged on and thet you can't close the file, but you can message them to ask them to close. Once they close, you can now close the file, Get ( UserCount ) returns 1 and the file is backed up.
Please note that the robot file does not have these limitations. (with the robot file, you'd modify this script to leave out the IF step as you don't care whether or not the file is being closed.)