restore one database from full backup

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


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-19-2007
nobody
 
Posts: n/a
Default restore one database from full backup

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


Reply With Quote
  #2 (permalink)  
Old 10-20-2007
Kees Nuyt
 
Posts: n/a
Default Re: restore one database from full backup

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)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:05 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0