6 Replies Latest reply on Feb 17, 2010 12:50 PM by TSGal

    Schedule VB System Script Fails to execute

    philmodjunk

      Title

      Schedule VB System Script Fails to execute

      Your post

      System Info: Windows Server 2003 sp2, FMS 10.

       

      This may become a bug report, but since I am fairly new to using FMS 10 to schedule a VB Script. I'll assume for the moment that I'm missing some key detail. The Information that I'm posting is quite lengthy so I will add more info in a second post.

       

      Here's the problem: FMS 10 won't back files up across the network to another computer's drive. Information from FM inc suggests using FM Server to back up files to a local drive and then use a system level script such as VB script to copy the files to a networked drive. I created the following VB script to calculate the name of the most recent back up folder and copy all its contents to a folder that's been shared and mapped as drive Z:

       

      After testing, I put a copy of this VB script in the FMS 10 scripts directory. If I right-click the file and open it with the Microsoft base scripts host, it correctly deletes any existing filemaker files from the destination folder and then copies the files over to this destination folder from the most recent back up folder. When I use FM Server to execute this script nothing happens. Looking for any possible information, I added code to this script to log any errors/or the lack of any error to a text file in the scripts folder. Again, performing this script from the command prompt or by using MS script host, successfully copies the files and generates the text file logging each step as being performed successfully. When I ran this script from a schedule in FMS, no files were copied and the text log was not created. No errors were reported in the log viewer.

       

      *******************************************************************************************************************

      On Error Resume Next

       

      Bfolder = "Daily_" & Year(date) & "-" & right("0" & month(date),2) & "-" & right("0" & day(date),2) & "_1730"

       

      FolderPath = "\\BackUps\\" & Bfolder & "\\FM Server Files\\"

       

      strComputer = "."

       

      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objtxtfile = objFSO.CreateTextFile("SendToZLog.txt")

       

      'Delete current copy of file

       

      Set objWMIService = GetObject("winmgmts:" _
          & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

       

      If Err then
         LogErrorInfo
      Else
        objtxtFile.Writeline ("No Error: Connect to root")
      End If

       

      Set colFiles = _
          objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '\\FM Server BU\\' and Extension = 'FP7'")

       

      If Err then
        logErrorInfo
      Else
        objtxtFile.Writeline ("No Error: Query Shared Folder")
      End If

       

      For Each objFile in colFiles
          objFile.Delete
          If Err then
             LogErrorInfo
          Else
             objtxtFile.Writeline (objFile.filename & " Deleted")
          End If

      Next

       

      'copy most recent back up files

       

      Set colFiles = _
          objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '" & FolderPath & "' and Extension = 'FP7'")

       

      If Err Then
        LOgErrorInfo
      Else
        objtxtFile.Writeline ("No Error: Query Back Up Folder")
      End If

       

      For Each objFile in colFiles
          strNewFile = "Z:\FM Server BU\" & objFile.FileName & ".FP7"
          objFile.Copy strNewFile
          If Err THen
             LogErrorInfo
          Else
             objtxtFile.Writeline ("Copied " & objfile.filename)
          End If
      Next

       

      objtxtfile.close

       

      Sub LogErrorInfo

         objtxtFile.Writeline (Err & "  " & Err.source & ", " & Err.Description)
         err.Clear

      End Sub

       

      ***********************************************************************

      Strangely, a simpler VB script that copies the files to a local folder on the same computer DOES work when scheduled by FM Server:

       

      *************************************************

      Bfolder = "Daily_" & Year(date) & "-" & right("0" & month(date),2) & "-" & right("0" & day(date),2) & "_1730"

       

      FolderPath = "\\BackUps\\" & Bfolder & "\\FM Server Files\\"

       

      strComputer = "."

       

      'Delete current copy of file

       

      Set objWMIService = GetObject("winmgmts:" _
          & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

       

      Set colFiles = _
          objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '\\Temp\\FM Server Files\\' and Extension = 'FP7'")

      For Each objFile in colFiles
          objFile.Delete
      Next

       

      'copy most recent back up files

       

      Set colFiles = _
          objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '" & FolderPath & "' and Extension = 'FP7'")

       

      For Each objFile in colFiles
          strNewFile = "D:\Temp\FM Server Files\" & objFile.FileName & ".FP7"
          objFile.Copy strNewFile
      Next

       










        • 1. Re: Schedule VB System Script Fails to execute
          MikeyG79
            

          Why use FM to schedule this?

          Our solution has FM doing it's "own" backup locally. We then have a Windows scheduled task disconnect all FM clients, shutdown the FM process - so the machine can safely be restarted.

          I'd do similar, but have it run your backup script. 

          • 2. Re: Schedule VB System Script Fails to execute
            MikeyG79
               Also, to save time and network transfer - look into using rsync.
            • 3. Re: Schedule VB System Script Fails to execute
              philmodjunk
                

              MikeyG79 wrote:

              Why use FM to schedule this?


              So we don't have to shut down FM server, we can just let it run. Performance isn't an issue since we can set this up to run at night when no one else is using the machines.

               

              I'll have two machines running FMS 10 when I'm done. I plan to send back up files from Server A to Server B and vice versa. That way, should the hardware for server A fail catastrophically, I can simply open the backed up copies on Server B and use Server B to host all files until we get Server A back up and running.

               

              Our primary backups will be backed up to a USB flash drive that the boss takes off site each evening. Since we can connect this directly to the server, FMS 10 will back up files to this drive without any problem.

               

              Back to the question:

               

              Why does the first script run correctly when it's executed from the command prompt or MS script host, but not from an FMS Schedule?

               

              Why does the second script work when scheduled and not the first?

               

               


              • 4. Re: Schedule VB System Script Fails to execute
                philmodjunk
                  

                Just a quick update. The issue is solved. This script can't run from FMS scheduler because it attempts to access a networked drive. It runs find when the OS runs it as a "Scheduled Task".

                • 5. Re: Schedule VB System Script Fails to execute
                  elizas
                  To check whether a script step is compatible or not and after schedule that script in FileMaker Server using the below
                  mentioned way:
                   
                  1. In Edit Script window, select Server from the Show compatibility option. Dimmed script steps are not compatible.
                  Based on this you can write specific piece of code as per your requirement and host the same in FileMaker Server.
                   
                  2. If by mistake any script step was left that are not supported, then it will halt the script execution. For avoid this need to turn Off the Allow User Abort script step at the top of that script.
                   
                  3. In FileMaker Server click on Create a FileMaker script schedule for each new schedule against Schedules
                   
                  Hope it did add value and was quite helpful.
                  Eliza
                  • 6. Re: Schedule VB System Script Fails to execute
                    TSGal

                    elizas:

                     

                    I sent you a private message (top of this page - right side - X Messages) last week.  Please read it.

                     

                    TSGal

                    FileMaker, Inc.