5 Replies Latest reply on Sep 7, 2011 6:25 AM by rjlevesque

    Backup script when closing this file problem



      Backup script when closing this file problem


       I have two tables: Student and AccessLog table, In my AccessLog table i have a global Count Field field so that FM would not increment record each time you close the application. I want FileMaker Pro 11 Advanced backup the current records (all records) in my AccessLog table when you close the application at the end of the day. I have the destination path already for the backup files to save/store and it works good.

      Let say first time you close the application, we have 10 records in the backup file. ("BACKUP" = name of backup file), then when you add another 5 records, then close the application it only update/or save the current records (10+5) = 15 records on that the same file or BACKUP file. That's my problem that I can't figure out how to solve this and because Im new in scripting.

      (Let say after we have "BACKUP" file in the destination area.)

      I want to:

      1. Have another file when I close the application containing the current records on the database. (Let say "BACKUP - 1" file in the destination area.), then

      2. Clear the records in database of AccessLog table for new records on the next time you open the application/system. The back to number 1, then number 2-loop.

      Here's my script:

      Set field [AccessLog::Count Field; AccessLog::Count Field + 1]

      If [AccessLog::Count Field > 0]

      Save a Copy as ["Day"; copy] # Day is the filename of a backpu file save on the designated path

      Set Field [AccessLog::Count Field;0]

      End If


      Please help and thanks in advanced.


        • 1. Re: Backup script when closing this file problem

          What is the purpose for doing this?

          It would be much simpler if you just saved a copy of the entire file to a different filename that always contained all of the records. Why delete some of them?

          • 2. Re: Backup script when closing this file problem

            Are you actually wanting a backup here or a log of activity on the solution?

            • 3. Re: Backup script when closing this file problem

              @PhilModlunk, The purpose of this is to save or backup daily (date/day is the filename) the current records of that specific day transactions in the destination storage and then clear the records of that day transactions after printing the records and closing the file. So that the following day when they open the system, it is clear and ready to receieved that particular day transactions and at the end of the day when they finished printing and closing the file, the same process will occur. Backup to the destination storage then clear the system for the following day transactions.

              Else please provide the script that will save all transactions in the database but if I want to print the particular date or that particular day, then I will find that date/day first and then show all that records then print it. Is that possible Phil?

              @rjlevesque, Yes, actually I want to automatically backup (using script) that daily transactions to the destination storage at the end of the day after printing that transactions as thier hard copy and then press the close button to close the file, In case I want to print that particular day/date, I'll find it again and print that records or transactions.

              Please help guys


              • 4. Re: Backup script when closing this file problem

                I don't see any advantage to segregating your data into separate files each for a different day's transactions. We routinely back up our transactions here on both hourly and nightly back ups (Nightly ones are verified and copied to external locations.), but we back up the entire file. Pulling up the transactions for a specified date is as simple as performing a find for records for that day. We use a schedule on FileMaker Server to do this, but a script that uses Save a copy can do this for files that are not hosted by server.

                By keeping the data together in a single file, you can also pull up summary reports on multiple days of business. Several of our reports are intended to span a time period of a specified start and end date, a specified month, quarter or year. We even have a 5 year comparsion chart that computes monthly totals over a specified 5 year interval. We would not be able to produce such reports if the data were split up like this...

                Our back up script looks like this:

                Set variable [$Path ; Value: //Path to backup directory goes here/ Get ( FileName ) & Let ( t = get ( Currentdate ) ; Year ( t ) & "-" & Right ( "0" & Month ( t ) ; 2 ) &  "-" & Right ( "0" & day ( t ) ; 2 ) & ".fp7" ) ]

                This saves the file to the specified location with the same name as the open file, but with today's date encoded into the file name so that multiple copies can be saved without overwriting existing copies. It's set up with the year first so that file names sort in correct order when you open the back up directory.

                • 5. Re: Backup script when closing this file problem

                  absolutely nothing to add here, Phil is 100% correct and covered it all...