Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Restoring select databases/tables from an --all-databases ..

 
   Database Help (Home) -> mySQL RSS
Next:  Bulk copy failure in restoring transactional publ..  
Author Message
Raffi

External


Since: Feb 15, 2005
Posts: 2



(Msg. 1) Posted: Tue Feb 15, 2005 2:01 am
Post subject: Restoring select databases/tables from an --all-databases ba
Archived from groups: mailing>database>mysql (more info?)

I use the --all-databases switch to backup my entire database.
Sometimes there's a need to restore individual databases or tables form
the backup file. What command should I use for this?

Thanks,
Raffi

 >> Stay informed about: Restoring select databases/tables from an --all-databases .. 
Back to top
Login to vote
bturczyn

External


Since: Jan 10, 2005
Posts: 7



(Msg. 2) Posted: Tue Feb 15, 2005 7:12 am
Post subject: Re: Restoring select databases/tables from an --all-database [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Taken from: Linux Server Hacks
By Rob Flickenger

Here is a method for restoring a single mysql table from a huge
mysqldump

Like a good admin, you faithfully dump your mysql tables every night,
and save them to the filesystem in compressed form (presumably to be
picked up by a backup script later). You probably have something like
this running in cron on your database server (or one of its replicated
slaves):

for x in `mysql -Bse show databases`; do
mysqldump $x | gzip -9 > /var/spool/mysqldump/$x.`date +%Y%m%d`.gz
done


This will cover you if anything catastrophic happens to your live
database. But if your database grows to an appreciable size, doing
partial restores can be difficult. On a database with several million
rows, your dumps suddenly become massive piles of data that need to be
sifted through. How can you easily restore a single table out of a
several hundred megabyte compressed dump?

Here's a simple method using Perl. Create a script called
extract-table, with this in it:

#!/usr/bin/perl -wn
BEGIN { $table = shift @ARGV }
print if /^create table $table\b/io .. /^create table (?!$table)\b/io;


To extract the User table from the dump of a database called randomdb,
try something like this:

# zcat /var/spool/mysqldump/randomdb.20020901.gz | extract-table Users
 > ~/
Users.dump


Now you can restore your Users table with a simple:

# mysql randomdb -e "drop table Users"
# mysql randomdb < ~/Users.dump

 >> Stay informed about: Restoring select databases/tables from an --all-databases .. 
Back to top
Login to vote
Raffi

External


Since: Feb 15, 2005
Posts: 2



(Msg. 3) Posted: Tue Feb 15, 2005 8:15 pm
Post subject: Re: Restoring select databases/tables from an --all-database [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Bill Turczyn wrote:
 > Taken from: Linux Server Hacks
 > By Rob Flickenger
 >
 > Here is a method for restoring a single mysql table from a huge
 > mysqldump
 >
 > Like a good admin, you faithfully dump your mysql tables every night,
 > and save them to the filesystem in compressed form (presumably to be
 > picked up by a backup script later). You probably have something like
 > this running in cron on your database server (or one of its
replicated
 > slaves):
 >
 > for x in `mysql -Bse show databases`; do
 > mysqldump $x | gzip -9 > /var/spool/mysqldump/$x.`date +%Y%m%d`.gz
 > done
 >
 >
 > This will cover you if anything catastrophic happens to your live
 > database. But if your database grows to an appreciable size, doing
 > partial restores can be difficult. On a database with several million
 > rows, your dumps suddenly become massive piles of data that need to
be
 > sifted through. How can you easily restore a single table out of a
 > several hundred megabyte compressed dump?
 >
 > Here's a simple method using Perl. Create a script called
 > extract-table, with this in it:
 >
 > #!/usr/bin/perl -wn

 > print if /^create table $table\b/io .. /^create table
(?!$table)\b/io;
 >
 >
 > To extract the User table from the dump of a database called
randomdb,
 > try something like this:
 >
 > # zcat /var/spool/mysqldump/randomdb.20020901.gz | extract-table
Users
  > > ~/
 > Users.dump
 >
 >
 > Now you can restore your Users table with a simple:
 >
 > # mysql randomdb -e "drop table Users"
 > # mysql randomdb < ~/Users.dump

That's exactly what is happening and many times only specific
tables/databases get corrupted and it's inefficient to restore the
complete database structure. I'll try the script out as soon as I get a
chance. I guess mysql doesn't have a built in feature that resores
individual tables and databases from a full backup and leaves
everything else alone.

Raffi
 >> Stay informed about: Restoring select databases/tables from an --all-databases .. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
PLS HELP! - show databases and tables and columns - Hi, I just wonder if someone can help me with this: I need to create a sql script which will run when user installs/upgrades my app. User may already have the database and tables tructure setup on the server, or may not. The script needs to..

Databases with different encodings - I run a MySQL Server (v. 4.1.5-gamma) from a binary distribution on a SuSE 7.0 Linux. The default character set for the server is utf8 (runs with the flag --default-character-set=utf8). The utf-8 encoded databases I have seem to work fine. But I want....

Stats comp.databases.mysql (last 7 days) - "Caveat: Quantity is not necessarily a measure of Quality" Newsgroup.................: comp.databases.mysql Stats Were Taken..........: Mon, 07 Dec 2009 09:10:02 GMT Stats Begin...............: Mon, 30 Nov 2009 09:20:43 GMT Stats..

Select more than just * - Is it possible to run a query like this: SELECT *, DATEDIFF(CURDATE(), `updated`) AS `daysSinceUpdate` FROM `Admin` Or should I let PHP calculate the days since update?

select with regexp - i have a column "path" with values eg. +---------------+ | path | +---------------+ |/path/path/path| +---------------+ |/path/path | +---------------+ |/path | +---------------+ i want to select the row where there are ...
   Database Help (Home) -> mySQL All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]