Database Backup Tool Sample Application

Discussion in 'Control Panel API' started by krmzbbr, Oct 24, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. 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
    Application & Source - desertrose.net/downloads/DiscountAspSqlBackup_Source.zip


    Emre

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

    Bruce DiscountASP.NET Staff

  3. 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
     
  4. 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.AppSettings["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.
     
  5. Bruce

    Bruce DiscountASP.NET Staff

    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
     
  6. 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.
     
  7. 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:





    Code:
    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:





    Code:
    [SoapException: Server was unable to process request. ---> Access denied.]
       System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +551452
       System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204
       SQL_Backup.net.discountasp.api.CustomerApi.Sql2005CreateBackup(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.Callback(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
    
     
  8. Bruce

    Bruce DiscountASP.NET Staff

    what's your domain and the IP you added? I'll check it out.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  9. Great tool...thnx...
     
  10. Thanks for the great tool !!
     
  11. 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...
     
  12. BTW, I have include the server's IP address in the white list (as suggested in a previous posting)
     
  13. Groovy, it works well.
    The only change I made was switch to https for secure download.

    Thanks!

    /emoticons/scool.gif
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page