This is a discussion on restore one database from full backup within the MySQL Database forums, part of the Database Forums category; I got a full backup of all my mysql databases to a dumpfile dumpfile.sql how do I restore only ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Fri, 19 Oct 2007 10:18:11 -0700, "nobody"
<nobody@nobody.com> wrote: >I got a full backup of all my mysql databases to a dumpfile dumpfile.sql > >how do I restore only one database from that dump file instead of >everything? > >thanks > I will assume you produced the backup with: mysqldump -u user -ppassword --all-databases >fulldumpfile You can filter your dumpfile, for example with awk (all on one line): Windows: awk "(($2==\"Current\") && ($4==\"`dbname`\")),(($2==\"Current\") && ($4!=\"`dbname`\")){print}" fulldumpfile >partdumpfile Unix: awk '(($2=="Current") && ($4=="`dbname`")),(($2=="Current") && ($4!="`dbname`")){print}' fulldumpfile >partdumpfile Once you have checked your partdumpfile, you can pipe the command to mysql (again, all on one line): awk "(($2==\"Current\") && ($4==\"`dbname`\")),(($2==\"Current\") && ($4!=\"`dbname`\")){print}" fulldumpfile | mysql -u user -ppassword Good luck -- ( Kees ) c[_] Famous last words - Don't worry, I can handle it. (#441) |