[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

database backup in CF

Posted on 2006-11-07
6
Medium Priority
?
375 Views
Last Modified: 2013-12-24
Hi,

i have a MS SQL database with all my products in, i wanted to know if it was possible in coldfusion to create a system where i could click a button and download a a sql file of the database as a backup to my desktop?

this sql file has to be one which could be used to restore my database if needed.


thanks
0
Comment
Question by:pigmentarts
[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
  • 3
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
bwasyliuk earned 2000 total points
ID: 17890870
The backup process (when done through Enterprise Manager as an example) is just a set of SQL commands run against the database.  I used SQL Profiler to "watch" what enterprise manager is doing when you run a backup - and you could easily do the same.

It appears as though something like the following will create the backup file:

<cfquery name="back_it_up" datasource="#session.mydsn#">
  BACKUP DATABASE [your_DB_name_here] TO  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\whateveryouwantyourfiletobe.bak' WITH  INIT ,  NOUNLOAD ,  NAME = N'My backup',  NOSKIP ,  STATS = 10,  NOFORMAT
</cfquery>

Assuming you can then do some CFFile actions on the file that is created above (file permissions etc) - then you should be able to write the script to download it.

Let me know if you want me to expand on this...

Ben
www.scheduleforce.net
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 17891222
thanks Ben, will look at this in the morining
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 17896525
i get this error....

 Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]BACKUP DATABASE permission denied in database 'testdatabase'.

but i do use the password like so...


<cfquery datasource="#dbSource#" username="#dbUsername#" password="#dbPassword#" name="backup">
  BACKUP DATABASE #dbSource# TO  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\whateveryouwantyourfiletobe.bak' WITH  INIT ,  NOUNLOAD ,  NAME = N'My backup',  NOSKIP ,  STATS = 10,  NOFORMAT
</cfquery>      

0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
LVL 7

Expert Comment

by:bwasyliuk
ID: 17898991
This is a permissions issue with the username you are using to connect.  Nothing wrong with the code as such - so I would go into the security are of enterprise manager and take a look at what the user is setup as.

There are a number of flags that can be set for the users access/privilages to the db, from memory I cant remember the exact name, but there is one that does say "backup" something in it.

Try turning that on for the user you are working with, and see what happens.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 17899024
thanks for your help! :)
0
 
LVL 6

Expert Comment

by:lightspeedvt
ID: 21363085
Hello, i have the same question. But in my case the SQL server is not the same machine the CF running. It is remote. I'm trying this

<cfquery name="back_it_up" datasource="#request.datasource#">
BACKUP DATABASE bgtaweb6 TO DISK = '\\10.2.9.89\dbbackup\bgtaweb6.bak' WITH  INIT ,  NOUNLOAD ,  NAME = 'bgtaweb6',  NOSKIP ,  STATS = 10,  NOFORMAT
</cfquery>

But get this error
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Cannot open backup device '\\10.2.9.89\dbbackup\bgtaweb6.bak'. Device error or device off-line. See the SQL Server error log for more details.

Could u pls help?
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

649 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