PDA

View Full Version : Database Backup Tool Sample Application


krmzbbr
10-24-2007, 06:27 AM
Hello,

I created an application to create scheduled backups of SQL 2005 databases.

UPDATE:I basically recreated the whole application:

-It connects to your site and checks for an existing backup. If a backup exists, checks the timestamp on the file and if it's current, it downloads the backup. If it's old backup it deletes the backup. (Backup call doesn't work if you already have backup in your root folder)
-Request an sync backup request using the API
-Connects to your site and downloads the backup and saves it with a date stamp (ie 10_24_2007_SQL2005_XXXXXX_XXXX_backup.bak). (Using the HTTP protocol instead of FTP - FTP caused firewall issues)
-It also supports logging now.

All you need to do is to put the API key, database name, domain name, ftp user name and ftp password in config file. Make sure that you don't run this application too often, you can only create backups every 6 hours.

Configuration details:

<add key='ApiKey' value='ApiKey' /> // Your Api key - required
<add key='DatabaseName' value='DatabaseName' /> // Database name - required
<add key='Domain' value='mydomain.com' /> // Domain name - required, (do not use www or ftp)
<add key='FtpUsername' value='FtpUsername' /> // Ftp user name - required
<add key='FtpPassword' value='FtpPassword' /> // Ftp password - required
<add key='BackupLocation' value='C:\Backup\' />// Backup location - optional

Source code is also attached.

Application - desertrose.net/downloads/DiscountAspSqlBackup_Exe.zip (http://desertrose.net/downloads/DiscountAspSqlBackup_Exe.zip)
Application & Source - desertrose.net/downloads/DiscountAspSqlBackup_Source.zip (http://desertrose.net/downloads/DiscountAspSqlBackup_Source.zip)


Emre

Post Edited (Emre) : 10/30/2007 5:32:49 PM GMT

bruce
10-25-2007, 07:56 AM
Emre,


This is very cool. Thank you for sharing.


Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

weinem01
12-01-2007, 10:13 AM
What an extremely useful tool for those of us that want to automate scheduled backups! I installed it and got it up and running in less than 10 minutes. If I may offer a suggestion, it would be great if the application would add a timestamp as well to the backed-up file to allow for more than one backup each day. My database has a lot of mission critical data that I would like to backup every 6 hours.

Thanks for creating this easy to use tool.

matt

browndogweb
01-08-2008, 01:52 AM
Just wanted to say thank you for taking the time to develop the backup appliaction for SQL 2005 databases!!

One question: I would like to take a scheduled backup from DiscountASP.NET's server instead of my local machine, so that I do not have to worry about my machine (laptop) being powered up in order to create the backup. I have created a really simple application that basically consists of the following code:


// Create a new instance of the CustomerApi Class
CustomerApi api = new CustomerApi();

// Create a backup of the database - will be stored in the root directory of the domain
api.Sql2005CreateBackup(ConfigurationManager.AppSe ttings["ApiKey"], ConfigurationManager.AppSettings["DatabaseName"]);


My problem is that when I run this code from DiscountASP.NET's server, I receive an "Access Denied" message, a message that I do not receive when I run the backup application from my local machine.

Any ideas as to why?

Thank you in advance for any help.

bruce
01-08-2008, 08:14 AM
You need to include the IP of the web server. Contact support and they can provide you the IP


Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

browndogweb
01-09-2008, 02:09 AM
Bruce:


I contacted support late this morning, and had my web server's IP Address by early afternoon. These guys are great!!! Thanks for your help.

browndogweb
01-09-2008, 11:18 AM
OK, I've added my server's IP Address to the IP Whitelist, but an still getting the "Access Denied" message. Any ideas?
Server was unable to process request. ---> Access denied.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Access denied.

Source Error:





An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:





[SoapException: Server was unable to process request. ---> Access denied.]
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +551452
System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String methodName, Object[] parameters) +204
SQL_Backup.net.discountasp.api.CustomerApi.Sql2005 CreateBackup(String key, String databaseName) in C:\Development\SQL_Backup\Web References\net.discountasp.api\Reference.cs:1528
SQL_Backup._Default.BackupDatabase() in C:\Development\SQL_Backup\Default.aspx.cs:65
SQL_Backup._Default.Page_Load(Object sender, EventArgs e) in C:\Development\SQL_Backup\Default.aspx.cs:44
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

bruce
01-10-2008, 02:56 AM
what's your domain and the IP you added? I'll check it out.

Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

stackchips
02-08-2008, 02:38 AM
Great tool...thnx...

mdmaidens
04-18-2008, 02:24 AM
Thanks for the great tool !!

boufos
05-12-2008, 01:34 AM
I have downloaded Emre's excellent tool, modified the app.config file w/ our account's specific information but I execute the application I receive
the following error:

5/12/2008 9:12:48 AM - *****************START*****************
5/12/2008 9:12:48 AM - Checking for existing backup...
5/12/2008 9:12:49 AM - Request async backup...
5/12/2008 9:12:50 AM - Server was unable to process request. ---> Access denied. <-------
5/12/2008 9:12:50 AM - *****************END*****************

What am I missing?

THNX for any help...

boufos
05-12-2008, 01:36 AM
BTW, I have include the server's IP address in the white list (as suggested in a previous posting)

FlyTheBlueSky
07-01-2008, 02:31 AM
Groovy, it works well.
The only change I made was switch to https for secure download.

Thanks!

/emoticons/scool.gif

krmzbbr
03-17-2009, 10:15 AM
Hello,

Just updated the application to work with the latest api.

http://community.discountasp.net/showthread.php?t=7558