Announcement

Collapse
No announcement yet.

Backup check script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Backup check script

    i've a modified version of the backup_check.txt script written by JohnWPB.

    One part of it I cannot debug to see why it's not working...

    The folder containing my backup files is c:\homeseer backup and the backup files in there are of the format -02-12-2006.zip (i.e. using the date in format dd-mm-yyyy).

    The script returns the message backup failed as it doesn't find the file created.

    This the bit that constructs the file name to check...

    sub ConstructFileName()
    'Contructs the file name to be checked

    ThisDay = day(now)
    ThisMonth = month(now)
    ThisYear = year(now)
    FullPath = dest_root
    FullPath = FullPath & "-" & ThisDay & "-" & ThisMonth & "-" & ThisYear & ".zip"
    end sub


    The rest of the script I believe is the same as the original posted. Can anyone tell me what I've done wrong?

    Malcolm
    Malcolm

  • #2
    Malcolm, one way that I find helps in debugging this kind of thing is to use the hs.speak commands to tell you what you have created - in this case the 'fullpath'. I would suggest using that or the msgbox command. This might help.

    Comment


    • #3
      Thanks Jeff that was helpful. I had been trying to use hs.writelog but the msgbox works well.

      I've now established that the filename construct is working as it should. It's then failing at the 'does this exist' check.

      Sub DoesItExist()
      ' Checks to see if the backup file exists.

      Set fso = CreateObject("Scripting.FileSystemObject")
      If (fso.FileExists(FullPath)) = true Then
      FileCheck = True
      Set fileCreated = fso.GetFile(FullPath)
      FileDate = fileCreated.DateCreated
      end if

      if (fso.FileExists(FullPath)) = false Then
      FileCheck = False
      end if

      Set fso = nothing
      Set f = nothing
      End Sub


      I did a check and FileCheck is resolving as false. Any ideas anyone why?

      Malcolm
      Malcolm

      Comment


      • #4
        It looks like you have not passed the Fullpath variable to the subroutine.

        Add the Fullpath to the call i.e.

        Call DoesItExist(FullPath)

        and for the subroutine:

        Sub DoesItExist(FullPath)
        Jon

        Comment


        • #5
          Sorry - not sure i understand that as that part of the script is the same as the one posted in the library http://forums.homeseer.com/showthrea...ghlight=backup

          Malcolm
          Malcolm

          Comment


          • #6
            Sorry, I thought it was something you had added.

            You need to see if the fullpath variable is correct. Add a msgbox command as shown.

            Set fso = CreateObject("Scripting.FileSystemObject")
            Msgbox FullPath
            If (fso.FileExists(FullPath)) = true Then

            If the path is correct, change the line to read:

            Set fso = CreateObject("Scripting.FileSystemObject")
            Msgbox fso.FileExists(FullPath)
            If (fso.FileExists(FullPath)) = true Then

            See what that returns.
            Jon

            Comment


            • #7
              Thanks Jon - spotted the error now.

              FullPath = FullPath & "-" & ThisDay & "-" & ThisMonth & "-" & ThisYear & ".zip"

              is returning -6-12-2006.zip when the file is named -06-12-2006.zip.

              ThisDay is dropping the leading zero. Any thoughts on how to solve that? That bug must have existed in the original script too I guess?

              Malcolm
              Malcolm

              Comment


              • #8
                You will need to add the following then:

                If Len(ThisDay)=1 then ThisDay="0" & ThisDay
                If Len(ThisMonth)=1 then ThisMonth="0" & ThisMonth
                FullPath = FullPath & "-" & ThisDay & "-" & ThisMonth & "-" & ThisYear & ".zip"
                Jon

                Comment


                • #9
                  Cracked! Thank you. Owe you one again! :-)


                  Malcolm
                  Malcolm

                  Comment


                  • #10
                    good stuff!

                    Do you intend to upgrade to HS2 or stick with HS1?
                    Jon

                    Comment


                    • #11
                      I'll be upgrading to HS2 between now and 31/12/06 - whenever i get a spare afternoon! :-)

                      Malcolm
                      Malcolm

                      Comment

                      Working...
                      X