11 Replies Latest reply on Mar 18, 2010 12:00 AM by bumper

    Insert Date and Time into backup file name

    LeoB

      Title

      Insert Date and Time into backup file name

      Post

      I have a backup script that runs every time the file is closed that backs up the file to a USB HDD.  It works fine, except that when it backs up it overwrites the previous backup.

       

      What I would like it to do is insert a timestamp into the actual backup file name so that every backup is kept.

       

      I tried naming the file "backup  & Get ( CurrentDate )," or for the timestamp, but neither worked.

       

      Any way to do this?

       

      Thanks.

        • 1. Re: Insert Date and Time into backup file name
          Steve Wright

          Hi Leo

           

          Set a variable to your desired path & filename first..

          Then specify the output file to that of your variable rather than trying to use calculations directly in the output file area.

          i.e

           

          Set Variable [ $file ; "filewin:/c/test/backup_" & Get(currentDate) & ".fp7" ]

          Save copy as [ $file ]

           

          Obviously using incorrect syntax above, but im sure you get the idea.

          • 2. Re: Insert Date and Time into backup file name
            LeoB

            SWS:

             

            The variable I tried to set is for AvseQC (the file name).

             

            When I try to specify the variable as:

             

            $AvseQC ; "filewin:/c/documents and settings/administrator/desktop/AvseQCbackup_" & (Get(CurrentDate)) & ".fp.7"

             

            It keeps giving me the error message of "An operator is expected here" and highlighting the string in blue.

             

            Now, on any given day I'm not the brightest bulb in the box, and when it comes to FM syntax, I have a dimmer switch.

             

            Any ideas what I'm doing wrong?

             

            Thanks.

             

             

            • 3. Re: Insert Date and Time into backup file name
              philmodjunk

              Try This:

               

              Set Variable [$Path ; Value: "filewin://--put filepath to your USB drive and folder here --/" & BackUp " & Subsitute ( Get ( CurrentDate ) ; "/" ; "-" ) & ".FP7"

              Save A Copy As [$Path ; Copy ]

              • 4. Re: Insert Date and Time into backup file name
                Steve Wright

                Sorry, I wasn't thinking about the date separators...  Even though I use the same method myself.. DOH !

                • 5. Re: Insert Date and Time into backup file name
                  philmodjunk

                  LeoB posted:

                   

                  $AvseQC ; "filewin:/c/documents and settings/administrator/desktop/AvseQCbackup_" & (Get(CurrentDate)) & ".fp.7"

                   

                  It keeps giving me the error message of "An operator is expected here" and highlighting the string in blue.

                   

                  Looks like you put the string in the wrong box after clicking specify... or you entered that leading semicolon instead of leaving it out.

                   

                  Put $AvseQC

                   

                  Then enter: filewin:/c/documents and settings/administrator/desktop/AvseQCbackup_" & Substitute(Get(CurrentDate)) ; "/" ; "-" ) & ".fp.7"

                   

                  in the second box. Filemaker will add "; Value: " for you when you check the script step in the  script editor.

                   

                  The substitute function gets rid of the "/" characters in the date which would otherwise be mis-identified as directory name separators.

                  • 6. Re: Insert Date and Time into backup file name
                    LeoB

                    Well, at the risk of becoming a PITA, I tried it and now it's not making any backup.

                     

                    Here's the script.  It's identical to the recommended one except for the backslash before the open paren before Backup.  It would not accept the script without it.

                     

                     

                    http://i44.tinypic.com/1111nde.jpg\

                     

                    Thanks.

                    • 7. Re: Insert Date and Time into backup file name
                      philmodjunk

                      Sorry, but it's not really identical. You've got some quotes where they shouldn't be and that's why it doesn't work.  Also, you have Substitute misspelled and this is keeping Filemaker from recognizing it.

                      • 8. Re: Insert Date and Time into backup file name
                        bumper

                        If there is any chance of someone making more than one backup per date, then you might want to reconsider the timestamp.

                         

                        Here's the one I use:

                         

                         

                        GetFileName & GetAsNumber ( Get ( CurrentTimeStamp ) ) & ".fp7

                         

                        by converting the timestamp to a number the likelihood of identical numbers is practically nil as it increases every second thus a new number and there are no hyphens or slashes to contend with. If you ever need to know the actual date and time a quickie two field db will convert it back to a timestamp for you.

                        • 9. Re: Insert Date and Time into backup file name
                          LeoB

                          Bumper:

                           

                          Thanks for the additional info.  Yes, I would expect multiple backups in a day, so this might be better,

                           

                          Unfortunately, I'm still totally lost at figuring out how to set the variable.  Nothing I do seems to work.  I spend about a half an hour a day trying to make it work, but then move on in frustration to something else.  I can't seem to find any basic tutorial on setting variables and the FMP Help seems to assume the user has vast programming experience.

                           

                          There's a canned script in FMP Help that I used to set the backup, and it works, but still only keeps the last backup as it overwrites it every time.

                           

                          One of these days I'll crack it!

                           

                          Thanks.

                          • 10. Re: Insert Date and Time into backup file name
                            philmodjunk

                            If you fix the errors I spotted, this should work for you.

                            • 11. Re: Insert Date and Time into backup file name
                              bumper

                              Here is my basic script:

                               

                              Set Variable [ $_NewFileName; Value:dev_Developer::GetFileName & "-" & GetAsNumber ( Get ( CurrentTimeStamp ) ) & ".fp7" ]

                              Set Variable [ $FilePath; Value:Get ( DesktopPath ) ]

                              Save a Copy as [ “$FilePath/$_NewFileName” ] [ compacted copy (smaller) ]

                               

                               

                               

                               

                              HTH