0

On a few of our sites we are running a backup script that saves a MSSQL database as a .bak file in a that directory.

Every day we run a Git style backup so that we have any changes to the site. Due to variance in backup timing We don't really want to delete today's backup, or yesterday's, so we will delete 3 days past.

The following .asp page runs fine if the DeleteFile(line 30) is commented out. if the file exists it follows the correct branch, so it can see the file, but if the delete line is uncommented it breaks.

<%@LANGUAGE="VBScript" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Purge</title>
</head>
<body>
    <%
        'Var init
        dim Month, Day, Year, Dir, File, Absolutepath, Period, fs
        Set fs=Server.CreateObject("Scripting.FileSystemObject")

        'setting date of backup for deletion to three days ago
        Period = dateadd("D", -3, Date)
        Month  = datepart("M", Period)
        Day    = datepart("D", Period)
        Year   = datepart("YYYY", Period)

        'location setting
        Dir = Server.MapPath(".") & "\"
        File= "dbBackup-" & Month & "-" & Day & "-" & Year & "_1.bak"
        Absolutepath = Dir & File

        'Actual attempt to delete
        If fs.FileExists(Absolutepath) Then
            fs.DeleteFile(Absolutepath)
            Response.Write("&#34;" & File & "&#34; deleted <br/>") 
        Else
            Response.Write("404: &#34;" & File & "&#34; missing <br/>") 
        End If
    %>
    Execution complete.
</body>
</html>

I have tried

'fs.DeleteFile(Absolutepath)

and

'fs.DeleteFile Absolutepath

and

'fs.DeleteFile(File)

and

'fs.DeleteFile File

To no avail. any ideas?

edit:

local server says 500 =

Microsoft VBScript compilation error '800a0414' 

Cannot use parentheses when calling a Sub 

/test/index.asp, line 23 

fs.CreateTextFile(Absolutepath,True)
kenneth
  • 43
  • 8
  • 1
    "*if the delete line is uncommented it breaks*", how exactly? What's the error message? – p.s.w.g Apr 29 '16 at 20:26
  • 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. even if i use the web.conig to try to force it to show – kenneth May 02 '16 at 12:29
  • All that tells me is that there was an error on the page. Also, if I recall correctly, web.config files had no relevance in ASP classic. See [this question](http://stackoverflow.com/questions/2640526/detailed-500-error-message-asp-iis-7-5) for help on displaying the actual error message. – p.s.w.g May 02 '16 at 13:40
  • I had used that code and got nothing from it, but someone pointed out that it was missing an end bracket. 'HTTP/1.1 New Application Failed' – kenneth May 02 '16 at 16:16

1 Answers1

0

The Answer ended up being that fs.DeleteFile does not take parenthesis

fs.DeleteFile(Absolutepath)

ended up being

fs.DeleteFile Absolutepath
kenneth
  • 43
  • 8