Is there a script that will save a copy as once a week or once a month automatically triggered by current date? is this even possible?
Yes totally doable. A script could use this. Through it in the data viewer and play with it. You are looking for a 1 (true) or 0 (false) as the result. That result would mean that both the date and the time were good (true). Days of the week are 1 - 7 (Sunday - Saturday). This would be the type of script that would be triggered on a Monday only at a certain time when your organization starts its day and keep FileMaker open. Lets say you close it and start it again you would have to set some slicker clause ( like a persistent variable) to make sure the system already ran this backup script.
Let ( [ @day = DayOfWeek( Get(CurrentDate) ); @gDay = If( @day = 4; 1 ; 0); @time = Get(CurrentTime); @gTime = If (@time ≤ "4:30:00 AM"; 1 ; 0) ]; @gDay and @gTime )
Here is a script that saves a normal backup copy manually. Don't forget it needs a global field. Now the trick would be to only let this run if a start up of your solution runs it on Monday at a certain time. I would a script trigger and incorporate the above logic. If you need more help just shout.
Show Custom Dialog [ Title: "Notes"; Message: "Enter a small suffix for your file. Make sure to use Windows OS accepted characters."; DefaultButton: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No”; Input #1: GLOBAL::xnotes ] Set Variable [ $fmbak; Value:Let ( [ @path = Left ( Get ( FilePath ) ; Position ( Get ( FilePath ) ; "/" ; Length ( Get ( FilePath ) ) ; -1 ) ); @date = FormatTimestamp( Get( CurrentTimestamp ); "%y%m%d%H%M" )]; @path & "/Backup/" & @date & "_" & Get(FileName) & "_" & GLOBAL::xnotes & ".fmp12" ) ] Save a Copy as [ “$fmbak” ] [ copy of current file ]
If your file is stored locally, then I would save the file every day to another location using, Save Clone with a trigger in the OnFirstWindowOpen script.
If it is on FileMaker Server, then you should have backups scheduled at least a couple of times every day, once a week and so on
Thanks Chris, I like this one but not sure how to write a script from beginning to end to make this work. Any help is appreciated.
@day = DayOfWeek( Get(CurrentDate) );
@gDay = If( @day = 4; 1 ; 0);
@time = Get(CurrentTime);
@gTime = If (@time ≤ "4:30:00 AM"; 1 ; 0) ];
@gDay and @gTime
Sure, could you tell me if you are on Mac or PC? What version of FileMaker are you using?
Using Windows, FMPA 16
The selected calculation has an error. It should be modified to be:
@gTime = If (@time ≤ getastime ( "4:30:00 AM" ) ; 1 ; 0) ];
OK perfect... I will work from there. Thanks
Hi, burns here is the file. Sorry it took so long. Work has been a zoo (and a circus). Hope you can work with it and the concepts. Any trouble just shout. I made a video to show some of what it does. Note, I could see this being a big topic, with a lot of suggestion for best practice. I encourage you to look for these concepts.
There are two scripts in the sample file that relate to what you want to do. There is also the backup script that can run automatically (now with the new time base automation) or manually when needed. Sometimes you may want to run a backup copy at a different than your set day you can anytime.The script Check Week Day checks to see if a value is present in a field. If it is not present, it knows you have not backed up your solution for your chosen day. It then performs the backup script and leaves the field in a state that lets FileMaker (your solution) know the backup has occurred for your chosen day. So now FileMaker knows it does not need to run this again today. The second script takes care of things when the file closes. If the value is present and you are on your chosen day for the backup. FileMaker leaves it in place. If any of the clauses are false, FileMaker will clear the field. Once cleared FileMaker will know that you need to perform a backup if you are on your chosen day of the week. Of course, this will happen when you open your solutions.
Working with logic and clauses like this takes some time to get used to. I know it did for me, so I would suggest anybody using this file take their time and test with the Data Viewer as much as they can.
The solution uses a custom function for its Backup Script. If you don’t know how to import the custom function into your solutions, just ask. I will need to be imported in for it to work.
Thank you for your help. Very useful
Retrieving data ...