Search code examples
mysqlrestoredatabase-restoremysql-backup

Mysql Restore from many dump files


We have an regular backup system which backs up every table from the DB into a separate files.

Like a table named

fo

will be dumped and compressed into a

foo.sql.bz2

I googled this kind of compresion and all i could think of to get it but i am out of ideas.

Anyone knows which tool is making backups like this and how can i restore the whole DB from milions of thouse files?

ps. We have over 700 tables, so resoring one by one is... kinda inpractical.


Solution

  • The .bz2 extension usually denotes a BZ2-compressed archive.

    To decompress:

    bzip2 -d foo.sql.bz2 # produces file "foo.sql"
    

    Combine with find, and the magic happens:

    find /path/to/dump/directory -name "*.sql.bz2" | xargs bzip2 -cd {} | mysql [options]