4 Replies Latest reply on Dec 19, 2011 1:19 PM by MichaelReese

    FileMaker System-level Script (Mac) copy database

    MichaelReese

      Title

      FileMaker System-level Script (Mac) copy database

      Your post

      Hello everyone,

      I'm looking for a way to make a copy of a production database and copy it to a test database.  Would like to update the Test database maybe every 30days or so.

      I have created a script and it works fine when I run it from the Mac in terminal.

      I then used the FileMaker Scheduler to run a system script and I get the message Aborted by user. (I have to use the system admin account to get this message)

      If I try to use the default account that FileMaker uses to run the script I receive invalid account.  Default account is fmserver.

      I have another script that is set to run with the default account and it works fine.

       

      Here is the script.

       #!/bin/bash

      #

      source="/Library/FileMaker Server/Data/Databases/Prod/Database_Prod.fp7"

      destination="/Library/FileMaker Server/Data/Databases/Test/Database_Test.fp7"

      cp -f "$source" "$destination"

      exit 0

       

      Thanks for your time and help

        • 1. Re: FileMaker System-level Script (Mac) copy database
          philmodjunk

          Is database_Prod.fp7 open at the time you try this?

          Does Database_Test.fp7 already exist at this point? If so, might it be open or write protected?

          Why not use the server schedule to just make a back up copy to that location?

          • 2. Re: FileMaker System-level Script (Mac) copy database
            MichaelReese

            - Yes the Database_Prod.fp7 is open when the script runs.

            - I have removed the Database_Test.fp7 and still the same issue.

            At this time we curently have 2 different backups running in filemaker and also a script that zips the database up and move them to a Tape.  I was just looking to keep it to one Scheduler if i could that the only reason. 

            The zip script works fine.

            Thanks.

            • 3. Re: FileMaker System-level Script (Mac) copy database
              philmodjunk

              - Yes the Database_Prod.fp7 is open when the script runs.

              This does'nt explain why it doesn't work, but you should never try to copy a file while it is open. This can produce a corrupted backup and techs here in the forum have even warned that it could corrupt the original though I have never seen an explanation of how that could be possible.

              I recommend you use a backup schedule as a scheduled backup is the only way to back up a file without closing it.

              If you are going to use a system script to copy a file, use the schedule to make the first copy, then have the system script copy the closed backup file. This is one way to move a backup off your server to a different, remote location. (System script cannot itself be scheduled if it will copy files to a remote location, it has to be run from a system based task scheduler.)

              I curently have 6 active schedules on one of my servers and 3 are back up schedules.

              • 4. Re: FileMaker System-level Script (Mac) copy database
                MichaelReese

                Thanks for all the help.

                 

                I worked on the script to use the data from the Backup of the database like you suggested.  

                This script now runs fine as the default account fmserver.

                 

                Here is the updated script.

                #!/bin/bash

                #

                source1="/Library/FileMaker Server/Data/Backups/"

                mostrecent=$(ls -1t "$source1" | head -n 1)

                source="/Library/FileMaker Server/Data/Backups/$mostrecent/Databases/Prod/Database_Prod.fp7"

                destination="/Library/FileMaker Server/Data/Databases/Test/Database_Test.fp7"

                cp -f "$source" "$destination"

                 exit 0