Created
March 27, 2009 11:09
-
-
Save rgo/86642 to your computer and use it in GitHub Desktop.
Restore table mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Restore table(table+data or only data) from mysqldump file | |
# | |
# NOTE: 'foo' is the table to restore and 'bar' next table in backup. | |
# Restore one table | |
zcat backup_20090316-0200.sql.gz | awk '/Table structure for table .foo./,/Table structure for table .bar./{print}' > output.sql | |
# Restore only data from one table | |
zcat backup_20090316-0200.sql.gz | awk '/Dumping data for table .foo./,/Table structure for table .bar./{print}' > output.sql | |
# Find backup files in subdirectories and restore only data | |
find . -wholename './*/*gz' -print | xargs zcat | awk "/Dumping data for table .foo./,/Table structure for table .bar./{print}" >> foo_data.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment