10 Replies Latest reply on Aug 23, 2013 8:08 AM by philmodjunk

    Backup script help

    Matty_1

      Title

      Backup script help

      Post

           Hello,

            

           I'm not sure if this one particular post got too old and fell behind so I'm re-posting with a quick link.  The original thread started on one subject and ended in a fairly long conversation about backing up.  I've put everything in place and it works fine but I'm looking for some help stepping back a few folders to save and a secluded backup folder.

           Check out the last post of the following link, not sure if I should be re-posting the entire thing or not.  Forgive me for not knowing customary practice for the forum.

           http://forums.filemaker.com/posts/d40c26a4d1?page=2

        • 1. Re: Backup script help
          philmodjunk

               Your last post read more like a "blog" entry than a request for help.

               Specifying a different folder for your backup using the save a copy as script simply requires doing some "surgery" on the expression for the path variable. The precise location of the folder for backups relative to your database file will determine what changes are made to the path you can get from the path to the database file's location.

          • 2. Re: Backup script help
            Matty_1

                 Right which is the help I'm looking for .... I just don't know if it's simpler to send you back to the original thread or re-post all the bits that tie to it.  I posted a reply on the one particular thread yesterday and hadn't heard anything so I figured it was too old ...  Should I collect all the important elements from the old thread and re-post?

            • 3. Re: Backup script help
              philmodjunk

                   Whichever, but what exactly is the question? I can tell you are having trouble getting it to work, but not what part of working with a file path is giving you that trouble. Can you post either here or there with a more specific description of where you are having trouble getting this to work?

              • 4. Re: Backup script help
                Matty_1

                      

                     What I'm hoping to achieve is stepping back a few folders to save in either a universal backup folder where all backup files just pile up or in a replicated file tree only for the backups.

                     The tree is as follows //.../Databases/NAME_OF_WORKING_FILE/ACTIVE_FILE

                     Depending which route I take, I would either have to remove all the folders leading up to the folder databases and have "Database-Backups" replaced OR pulling out the folder databases and replace it with database-backups and have the rest the same.  Makes sense?  Is there  a way to check if the folder exists and if not create the path automatically?

                     With either setup this will allow me to remove the entire "database" folder from the time machine backups and I won't have to remember to individually remove any as I create new ones in the future.

                      

                • 5. Re: Backup script help
                  philmodjunk
                       

                             Is there  a way to check if the folder exists and if not create the path automatically?

                       Not using just FileMaker scripts. You'd need to use either a system script or a plug in to check for a missing folder and also to create that folder.

                       Once the folder is in place you can either specify the path to that folder as literal text or calculate it using the path to your database file as a starting point. That is a matter of setting up the needed calculation for your $Path variable with text functions--particularly using the Position function to check for the position of specific instances of the / character.

                       To compute:

                       //.../Databases/backups/BackupFileName.fmp12

                       from

                       //.../Databases/NAME_OF_WORKING_FILE/ACTIVE_FILE.fmp12

                       You could use:

                       Let ( [ F = Get ( FilePath ) ;
                                 L = Length ( F ) ;
                                 folderpath = Left ( F ; Position ( F ; "/" ; L ; -2 ) ) & "Backups/" ;
                                 period =  Position ( F ; "." ; L ; - 1 ) ;
                                 slash = Position ( F ; "/" ; L ; - 1 ) ;
                                 ex = Right ( F ; Length ( F ) - period + 1 ) ;
                                 filename = Middle ( F ; slash + 1 ; period - slash - 1 ) & " " &
                                             Substitute ( Get ( CurrentTimeStamp ) ; ["/" ; "-"] ; [":" ; " " ] ) & ex
                                  ] ;
                                 folderpath & filename
                              ) // Let

                  • 6. Re: Backup script help
                    Matty_1

                         Sorry, I had originally mentioned this in the other thread and when I copied over some of the information I forgot to mention it again.  What I'm hoping to do is have the backup folder sit beside the database folder to allow me to simply block time machine from touching the entire database folder.  That way no matter what I create in the future I don't need to remember to go to timemachine setting to remove the newly added file.

                         So with that idea I would put the file in the database folder following the same format mentioned earlier and have a script that backs out to where the database folder is and saves to a folder named database-backups.  This script will allow me to place the file on any machine and in any area and as long as I have a folder called database and a folder called database-backups right beside it and follow the same folder tree structure I can let it do it's thing completely on it's own without having to manually copy in a path.

                    • 7. Re: Backup script help
                      philmodjunk

                           Except for automatically creating the folder, what I have described in my previous post should do that. it saves the file to a folder named backups just inside the databases folder.

                           And if you want to specify a different location, what I posted should serve as a model for how you would set up that file path calculation.

                      • 8. Re: Backup script help
                        Matty_1

                             You're correct, got it working.  Sorry about that and thanks for your help!

                        • 9. Re: Backup script help
                          Matty_1

                               I'm picky when it comes to file order and simple thing like not having the files be in perfect chronological order because there isn't a "0" in front of say 9 56 ( in the 24 hour clock) bugs me.  So I set out to add the "0" in front of single digit hours so everything stays in perfect order but I've hit a road block.  I'm stumped as to how I get the rest of the time back into play.  What I've done in the following code is reformatted the time to be on a 24 hour clock with a custom code.  I then pulled out the hour from the time and added a "0" in front when the hour is a single digit.  I don't know how to get the minutes and seconds back in though ....

                                

                               
                                    Let ( [ 
                               
                                     
                               
                                    F = Get ( FilePath ) ;
                               
                                    L = Length ( F ) ;
                               
                                    folderpath = Left ( F ; Position ( F ; "/" ; L ; -3 ) ) & "Backups/" ;
                               
                                    period =  Position ( F ; "." ; L ; - 1 ) ;
                               
                                    slash = Position ( F ; "/" ; L ; - 1 ) ;
                               
                                    ex = Right ( F ; Length ( F ) - period + 1 ) ;
                               
                                    Date = Substitute ( Get ( CurrentDate ) ; ["/" ; "-"] ) ;
                               
                                    Time = Substitute ( TimeFormatAs ( Get ( CurrentTime ) ; 24 ) ; [":" ; " "] ) ;
                               
                                    TimeFormat = Right ( "0" & Left ( Time ; Position ( Time ; " " ; 1 ; 1 ) - 1 ) ; 2 ) ;
                               
                                    filename = Middle ( F ; slash + 1 ; period - slash - 1 ) & " " & Date & " " & TimeFormat & ex
                               
                                     
                               
                                    ] ;
                               
                                     
                               
                                    folderpath & filename
                               
                                     
                               
                                    ) // Let
                          • 10. Re: Backup script help
                            philmodjunk

                                 Try something like:

                                 Let ( [ T = Get ( CurrentTIme);
                                            H = Right ( "0" & Hour ( T ) ; 2 );
                                            M = Right ( "0" & Minutes ( T ) ; 2 );