|
-
Jul 1st, 2009, 11:11 AM
#1
Thread Starter
Lively Member
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
-
Jul 1st, 2009, 11:40 AM
#2
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
-
Jul 1st, 2009, 10:42 PM
#3
Thread Starter
Lively Member
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
-
Jul 1st, 2009, 11:03 PM
#4
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
-
Jul 2nd, 2009, 02:43 AM
#5
Thread Starter
Lively Member
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
-
Jul 3rd, 2009, 01:11 AM
#6
Re: database backup
 Originally Posted by sridharao
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|