Results 1 to 6 of 6

Thread: database backup

Hybrid View

  1. #1

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    database backup

    I have looking for ways to let the user backup database files. I stumbled upon this code:

    PHP Code:
    <?php
    include 'config.php';
    include 
    'opendb.php';

    $tableName  'mypet';
    $backupFile 'backup/mypet.sql';
    $query      "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
    $result mysql_query($query);

    include 
    'closedb.php';
    ?>
    I have a few questions here; what are the config, opendb and closedb.php files and why are we calling them? Are they inbuilt or created by the programmer?

    I don't want to backup the files to the same drive where the files currently reside. I want the user to select a location/drive on his computer. And then save this path/location ....something like...$backupFile = D:/secure/backup.sql. How is this possible?

    Does the above quoted procedure export the database with structure and data to an sql format?
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: database backup

    First things first...what kind of database are you looking to back up? SQL Server, Acces, mySQL, Oracle, etc? Second, is this going to be a web-based app? running on a webserver somewhere, or do you intend for this to be an application that runs on a user's machine? That last one is the more important one, as if it's a web app, then it won't be able to just write out the file to the user's local machine... you would have to generate the file, then redirect them to it, which should then prompt the "What do you want to do with this file?" dialog, at which point the user can select where to save the file.

    For some of your other questions - yes, the included php files were external files being used by the programmer... they probably contain some useful functions to do configuration and DB access.

    As for if it saves the structure and data.... I'd say data yes, structure, probably not.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Re: database backup

    I am sorry for not making it clear. My application uses mysql databases on Apache server. Actually, I intend to use them on user's desktop but at the same time it will be on web for demo purpose too. Hence, I believe the code will vary according to the situation. Either way, how to go about it?
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: database backup

    What site did you obtain the above code from?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Re: database backup

    The quoted code is available at http://www.php-mysql-tutorial.com/wi...databases.aspx

    I found another seemingly good code at http://www.devpapers.com/article/55
    I tried this out but it generate a .sql file that is full of errors and blank fields.

    Searching through the net, I came across yet another script, which works, have look at this link http://www.fluffycat.com/SQL/MySQL-D...ckup-With-PHP/
    It generates a .sql file and there is provision to restore the files as well. But, can I tweak it to make the desktop user to select the location to save the file and later how to select the file for restoring the tables?
    Last edited by sridharao; Jul 2nd, 2009 at 04:02 AM.
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

  6. #6
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: database backup

    Quote Originally Posted by sridharao View Post
    I tried this out but it generate a .sql file that is full of errors and blank fields.
    It appears the author forgot to copy the contentss of the original file before trying to copy the data to the new sql database. As shown in the fluffycat code you have linked to the author connects to, selects, then loops through the data in the database before trying to copy it.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width