Reputation: 4132
I accidentally empty a table. I have backup, but the backup is the whole database, about 10GB. How can I just restore one table from the backup? Is it possible?
Upvotes: 2
Views: 1748
Reputation: 13812
$ awk '/Table structure for table .test1./,/Table structure for table .test2./{print}' mydumpfile.sql > /tmp/extracted_table.sql
Upvotes: 1
Reputation: 108380
You'd need to extract just the one table from the backup SQL.
You can do this using sed, e.g.
sed -n -e '/CREATE TABLE `mytable`/,/CREATE TABLE/p' backup.sql > mytable.sql
(This works as long as its not the last table in the dump (I think). The output file will include an extra line, a partial CREATE TABLE statement.)
Upvotes: 0