Our blog
MySQL Dump Partial Restore – Split MySQL Dump into Tables
MySQL dumps are often used as a quick and easy way of backing up an entire MySQL database in one go. However, they are only really designed to restore whole databases as well. So what if you only want to restore certain tables?
I have written this nice little PHP script which will take your dump file and split it into lots of little sql files - one for each table. You can then restore which ever tables you want.
Simply create a php file in the same directory as your dump file. Name it something easy to remember. Then go to it in your web browser, input the name of the dump file and click go.
As this is a fairly massive task (depending on the size of your dump file) you may find it works better on your local test server with some generous php_ini settings for max_execution_time etc.
-
<?php
-
/*MySQL Dump Split to Tables
-
* script supplied by Edmonds Commerce
-
* www.edmondscommerce.co.uk
-
* if you like it, please link back with a do-follow
-
*/
-
echo '<h1>MySQL Dump Split to Tables</h1>';
-
echo '<form><b>Dump File Path:</b> <input name="dump_file"> <input type="submit" value="go"></form>';
-
}else{
-
if ($handle) {
-
}
-
$table_name = $matches[1];
-
}else{
-
}
-
}
-
}
-
}
-
}
-
echo '<h1>Done</h1>'
-
?>
More Reading:
7 Comments
|
Excellent piece of coding. Had an error in the mysqldump that prevented to whole backup from being restored. With your script it was easy to do a partial restore. Thanks, Marius |
|
admin May 10th, 2008 |
glad you liked it |
|
Hey Edmond, thanks for the link. Adds nicely to my blog post on my way of doing partial restore. |
|
Joe July 13th, 2009 |
Any way to just pull out one entire data base and not just all the tables? |
|
Nice thank you! TODO |
|
Izak November 24th, 2011 |
Hmm... this doesn't work for me... I doubt it is supposed to look like this when i open it in browser: http://shrani.si/f/2x/4X/11GT8NYg/captured-photo.jpg |
|
I didn't find php_ini |
RSS Feed
marius
May 10th, 2008