1

I have a 15GB sql file which is a backup of a database. The problem I have is that half way through it, it failed. Luckily, I know which table to pick up from.

Is there a way I can split this SQL file by the starting point of the table I need to pick up from or perhaps get mysql to do this itself?

Thanks

David
  • 841
  • 3
  • 14
  • 31

2 Answers2

1

You could use sed to split the file using ranges

sed -n '/Start Text/,/End Text/p' >part.sql

This will start printing when /Start Text/ is found and will continue printing until /End Text/ or end of file is reached. Make sure Start Text is unique to the starting point and End Text isn't in the file.

user9517
  • 115,471
  • 20
  • 215
  • 297
0

You can use the split command (look into the line count option), or you can use dd with a byte offset (found using grep -b) to extract from your dumpfile as well.

Here's a blog post that covers that process (this is an answer I gave elsewhere on the site and decided to blog the solution).

thinice
  • 4,716
  • 21
  • 38