LinHES Forums
http://forums.linhes.org/

Extract one table from mysql backup
http://forums.linhes.org/viewtopic.php?f=5&t=19825
Page 1 of 1

Author:  mihanson [ Mon Apr 27, 2009 11:07 pm ]
Post subject:  Extract one table from mysql backup

I'm running R6 and I accidently hosed my channel table. I was able to "fix" it, but I just could not duplicate my channel mappings the way I used to have it. I'm not so good at mysql, but I'd like to extract my old channel table from my mythconverg.sql.gz. Can anyone help me accomplish this?

Author:  willem [ Tue Apr 28, 2009 1:52 am ]
Post subject: 

You could try this:

Code:
zcat mythconverg.sql.gz | grep "INSERT INTO \`channel\` VALUES" > channel-table.sql

Author:  tjc [ Tue Apr 28, 2009 9:41 pm ]
Post subject: 

1) Make another backup before you start messing with the DB!

2) Beware that using that naked insert may either cause duplicates or fail depending on the key settings for that table. You either need to clean the table out first or drop/recreate it. Cleaning it out is simpler and probably adequate, this should do the trick.
Code:
delete from channel;

Author:  goofee [ Wed Apr 29, 2009 12:19 am ]
Post subject: 

I usually hand edit the file. I'm not confident with my grep skills.
Anything after
Code:
-- Table structure for table `channel`

will drop the table and recreate a blank table structure to avoid duplicates and reset the auto increment counter if applicable.
Code:
-- Dumping data for table `channel`

The stuff after this is the data your looking to keep.
Something like this should load it
Code:
mysql -u mythtv -p -D mythconverg < backup.file.name

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/