in reply to Backup Sql databse
I don't know why your script "fails" or why the file gets removed (maybe by the database server). Consider looking at the webserver error logs or the database server error logs.
In the long run, you don't want to run your backup(s) with the hope that the user keeps their browser window open and that the browser does not time out. See Watching Long Processes Through CGI for a technique to show a "please wait" or a "backup progress" page while the backup gets generated.