Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Backup on Hosting Server

Status
Not open for further replies.

Nilgni

Instructor
Feb 21, 2002
58
0
0
US
I would like to make a backup routine to automatically generate a copy of the MS Access database daily. I am hosting with 1and1.com and using asp.

Ideally it would be in a folder where the original is located and it would do it without any user initiation at an early morning hour. Once I get that, I would like to delete any copies that are more than a week old from the same folder. If it isn't possible to schedule an automatic backup I would be happy to settle for a user initiated one.

I have been able to do this locally in the past, but not online. I am new to asp and have only a basic background.

I searched google and many locations looking for a tutorial, but all I could find was stupid search pages that delivered ads. I hate those things. If you know any tutorials or where I can find a company that offers this please let me know. When I find the answer I was thinking of putting an FAQ on the topic together. Seems like it wouldn't be that hard to find - doesn't everyone backup their stuff?

Thanks,
Keith
 
Found this:
Ashley Rudland DMX forum Feb 17, 2004

<% Option Explicit %>
<%
'Dimension variables
Dim objJetEngine 'Holds the jet database engine object
Dim objFSO 'Holds the FSO object
Dim strCompactDB 'Holds the destination of the compacted database
Dim strDbPathAndName
Dim strCon

strDbPathAndName = Server.MapPath("database.mdb")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strDbPathAndName
%>
<html>
<head>
<title>Compact and Repair Access Database</title>
</head>
<body>
<h2>Compact and Repair Access Database</h2>
<br />
<%
'If this is a post back run the compact and repair
If Request.Form("postBack") Then %>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<ol>
<%

'Create an intence of the FSO object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'Back up the database
objFSO.CopyFile strDbPathAndName, Replace(strDbPathAndName, ".mdb", "-backup.mdb", 1, -1, 1)

Response.Write(" <li>Database backed up to:-<br/><span>" & Replace(strDbPathAndName, ".mdb", "-backup.mdb", 1, -1, 1) & "</span><br /><br /></li>")



'Create an intence of the JET engine object
Set objJetEngine = Server.CreateObject("JRO.JetEngine")

'Get the destination and name of the compacted database
strCompactDB = Replace(strDbPathAndName, ".mdb", "-tmp.mdb", 1, -1, 1)

'Compact database
objJetEngine.CompactDatabase strCon, "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strCompactDB

'Display text that new compact db is created
Response.Write(" <li>New compacted database:-<br/><span>" & strCompactDB & "</span><br /><br /></li>")

'Release Jet object
Set objJetEngine = Nothing




'Delete old database
objFSO.DeleteFile strDbPathAndName

'Display text that that old db is deleted
Response.Write(" <li>Old uncompacted database deleted:-<br/><span>" & strDbPathAndName & "</span><br /><br /></li>")



'Rename temporary database to old name
objFSO.MoveFile strCompactDB, strDbPathAndName

'Display text that that old db is deleted
Response.Write(" <li>Rename compacted database from:-<br/><span>" & strCompactDB & "</span><br />To:-<br /><span>" & strDbPathAndName & "</span><br /><br /></li>")


'Release FSO object
Set objFSO = Nothing


Response.Write(" The Access database is now compacted and repaired")

%></ol></td>
</tr>
</table>
<%
Else

%>
<p class="text"> Please note: If the 'Compact and Repair' procedure fails a backup of your database will be created ending with '-backup.mdb'.<br />
</p>
</div>
<form action="this_file_name.asp" method="post" name="frmCompact" id="frmCompact">
<div align="center"><br />
<input name="postBack" type="hidden" id="postBack" value="true">
<input type="submit" name="Submit" value="Compact and Repair Database">
</div>
</form><%

End If

%>
<br />
</body>
</html>
Now all I need to do is change a few parameters and make it so it outputs a naming convention with a date appended to the database.mdb name. It is a great start... more to come

Keith
 
If this site is important to you, I strongly recommend that you back up everything to another location entirely. Web hosts have been know to make mistakes, vanish, develop long down-times and so on, quite apart from malicious tampering.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top