?
Solved

Backup and Restore of SQL Server database using ASP

Posted on 2003-03-15
10
Medium Priority
?
635 Views
Last Modified: 2006-11-17
How do i do programmatically the backup and restore of SQL Server database using ASP?

Any Help?

thanks
Ramu Arumugam
0
Comment
Question by:araman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 4

Accepted Solution

by:
arthuryeung earned 200 total points
ID: 8141940
This is the link you can take a look, I also successfully doing similar task with this reference:

http://www.asp101.com/articles/carvin/sqldmobackup/default.asp

0
 
LVL 4

Expert Comment

by:arthuryeung
ID: 8141943
The above one is for backup, here is the link for restore:

http://www.databasejournal.com/features/mssql/article.php/10894_1479521_2
0
 
LVL 7

Assisted Solution

by:lavinder
lavinder earned 200 total points
ID: 8141959
Hi

 i think one of the most efficient and powerful approach is to use a stored procedure for this purpose and call it using asp. try this link:
 http://www.swynk.com/sqlhome/backuprest7.asp
 http://www.sswug.org/see.asp?s=1166&id=12707

 another technique is using WMI, here is a relevant link:
http://www.databasejournal.com/features/mssql/article.php/1559341

 i would like to suggest that you create 2 stored procedures using BACKUP and RESTORE commands in TSQL and call them using asp. Simple and easy to implement. In SQL Server documentation, you can find example code for that also.

cheers!!

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:lavinder
ID: 8141972
You can also use SQL-Distributed Management Objects for this purpose, here is the relevant link (one already posted by arthuryeung !!):

http://www.sqlservercentral.com/columnists/awarren/restoringusingdmogettingfilelistandnorecovery.asp
0
 

Expert Comment

by:mrbasil
ID: 8143808
I use this piece of code to backup my database.

<%
dim fs, f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(Server.MapPath("PMS.mdb"))
fs.CopyFile Server.MapPath("PMS.mdb"),Server.MapPath("PMS2.mdb")
set f=nothing
set fs=nothing
%>

This code will backup the database when ever it is run, if you put this code in an IF statement along with the previous code it will only backup the database if the database is over a week old.

"If f.datecreated - date < 7 then"

If you need to restore your working copy with the backup use this code:
<%
dim fs, f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(Server.MapPath("PMS2.mdb"))
fs.CopyFile Server.MapPath("PMS2.mdb"),Server.MapPath("PMS.mdb")
set f=nothing
set fs=nothing
%>

Hope this helps.
luke
0
 
LVL 4

Expert Comment

by:arthuryeung
ID: 8145108
mrbasil:

he is trying to backup a SQL server but not an Access database.
0
 

Expert Comment

by:mrbasil
ID: 8145966
Does it make any difference at all arthuryeung? He would just need to remove PMS.mdb and replace it with his own file name.
0
 
LVL 4

Expert Comment

by:arthuryeung
ID: 8146705
mrbasil:

There's a big different. lol

you can't backup a SQL server just by copying the data file.
1. the SQL server data file is exclusively read/write locked by the SQL server process.
2. not all information about the database is stored in the data file , like Access does. some data are stored in the master database and some are in transaction files
3. even you copy all related files, you still can't restore a database

I guess you have never use SQL server before.
0
 

Expert Comment

by:mrbasil
ID: 8147075
Lol cheers! arthur, i havent actually. Thats too costly for a poor young lad like myself. I survive on pocket money of £25 a week, lol i cant afford cool stuff. Thanks for the correction.
0
 
LVL 58

Expert Comment

by:Gary
ID: 9349755
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split Points - arthuryeung / lavinder

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question