12 Replies Latest reply on Aug 29, 2013 11:48 AM by philmodjunk

    How to create a Backup script in database

    AnnieHsieh

      Title

      How to create a Backup script in database

      Post

           I wanted to backup my database the other day and so I've created a new script named "Backup"

           Here's what I've got

           Set Variable 

           Name: $ABC.fmp12

           Value:"backup_" & DayName

           Repetition 1

            

           Save a Copy as

           compacted copy

            

           I run in but it didn't seem to work

        • 1. Re: How to create a Backup script in database
          philmodjunk

               An actual screen shot of the script in your script editor would be helpful as the details make a difference.

               You may find this thread helpful. It uses more bells and whistles for automatically saving a file under development every few minutes but you should see examples in the scripts posted where the file name and path is assigned to a variable and then used in the save a copy as script step: Saving Sequential Back Ups During Development

          • 2. Re: How to create a Backup script in database
            philmodjunk

                 You don't need the Install OnTimerScript portion unless you want to save a new back up copy of your file every 15 minutes. But then you haven't specified in this thread when you would want to save back up copies either. Some just run the script you call backup II manually or set up File Options to run that script each time you close the file--just to list some other options.

                 The 15 minute interval I specified in the other thread was for a file that was undergoing frequent and major design changes so that you can use the back up copies to roll back a change if you later discover that such a change was not a good idea.

                 The $Path variable is used by Save A Copy As to specify both the name of the back up copy and the location to where it will be saved. Part of the calculation is designed to extract the database file's file extension in order to specify it as part of the file name. That change enables the same script to work with either FileMaker 11 or FileMaker 12 files.

                 To learn more about $Path Variables and the scripts that can use such a variable, see this thread and the demo file you can download from it: Exploring the use of a $Path Variable in Scripts

            • 3. Re: How to create a Backup script in database
              AnnieHsieh

                   So does that mean I will only need the "backupB" script ? 

                   So just these would work?

                   Set Variable [ $Path; Value:Let ( [ F = Get ( FilePath ) ] ; Left ( F ; Position ( F ; "." ; Length ( F ) ; -1 ) - 1 ) & " " & Substitute ( Get ( CurrentTimeStamp ) ; ["/" ; "-"] ; [":" ; " " ] ) & ".fmp12" ) // Let ]

                   Save a Copy as [ “$Path” ] [ copy of current file ]

              • 4. Re: How to create a Backup script in database
                AnnieHsieh

                     I'm still not sure if I understood correctly. Do I write NANW2013Copy.fmp12 ( this is the new file name I give for the backup file) as my "Path" or just put $Path ?

                • 5. Re: How to create a Backup script in database
                  philmodjunk

                       That's all you need to script the saving of a back up copy of your file. The other script is a method for saving that copy on regular, periodic intervals.

                       As written in my example script, you just put in $Path. But that requires that $Path begiven the correct value for specifying a valid filepath and file name to specify where the file will be saved and what it will be named. That part is controlled by your set variable script step that assigns a value to this variable.

                       The value that my example assigns to $Path is a path to the same folder as where your original file is located. IT appends timestamp data as part of the file name so that each copy saved has a unique file name so that multiple copies of the data is preserved.

                       That need not be the location where you want to store your backup files nor the name used when saving the file. Other locations/names are also possible.

                  • 6. Re: How to create a Backup script in database
                    philmodjunk

                         What do you mean by "index"?

                         If you aren't getting an error message popping up, you should be getting new copies saved, but maybe not in the location where you expected to see them. What I see should save a new copy of the file to the same folder where the database file itself is located.

                    • 7. Re: How to create a Backup script in database
                      AnnieHsieh

                           Okay yea when I click on the script nothing pops up, what should I type in the spotlight to find the copies do you know?

                      • 8. Re: How to create a Backup script in database
                        philmodjunk

                             Search for files with the same name as your database file. The script should be saving the copies with the same name plus additional text from the timestamp value. The files should be located in the same folder as your database file anyway.

                        • 9. Re: How to create a Backup script in database
                          AnnieHsieh

                               I searched but couldn't find them. I am using open remote instead of opening the db from a folder does that matter?

                          • 10. Re: How to create a Backup script in database
                            philmodjunk

                                 It very much matters. Try manually selecting "save a copy as" from the file menu. You'll find that "save a copy as is" not available when you are opening the file as a client of a hosted database file.

                                 Your Save a copy script would need to be run from the host computer, not a client.

                                 And if you are hosting the file with FileMaker Server, you do not need this script at all as you can set up a back up schedule for the server to generate your back kup copies.

                            • 11. Re: How to create a Backup script in database
                              AnnieHsieh

                                   How do I set up a back up schedule for the server? Thanks so much for your help!

                              • 12. Re: How to create a Backup script in database
                                philmodjunk

                                     I'm using Server 10. The details for 11 and 12 server consoles could differ a bit...

                                     Launch the Server Admin Console to access FileMaker Server

                                     Click "Schedules"

                                     Select "Create a Schedule" from the the action drop down and click "perform action".

                                     Select the "back up databases" option and follow the wizard step by step to set up a back up schedule. You can back up a single file or all the files in the same folder.