Pergunta

We have a yesterdays "full backup file(daily_3101013.sql)" it's size is 1TB. We are taking full bakup by using Percona-XTRA BACKUP. So now I want one table backup/data from my full backup file(daily_3101013.sql)for restoring/import purpose.

encountering problem with restoring the table. The error you are getting is supposedly “Got error -1 from storage engine”.

How can I do that?

please help me here.

Foi útil?

Solução

I've created a bash script to spit a full DB dump to one SQL file per table.

Checkout and download the gist Split MySQL dump SQL file into one file per table

To extract a single table run mysql_splitdump.sh daily_3101013.sql mytable.

#!/bin/bash

####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####

if [ $# -lt 1 ] ; then
  echo "USAGE $0 DUMP_FILE [TABLE]"
  exit
fi

if [ $# -ge 2 ] ; then
  csplit -s -ftable $1 "/-- Table structure for table/" "%-- Table structure for table \`$2\`%" "/-- Table structure for table/" "%40103 SET TIME_ZONE=@OLD_TIME_ZONE%1"
else
  csplit -s -ftable $1 "/-- Table structure for table/" {*}
fi

[ $? -eq 0 ] || exit

mv table00 head

FILE=`ls -1 table* | tail -n 1`
if [ $# -ge 2 ] ; then
  mv $FILE foot
else
  csplit -b '%d' -s -f$FILE $FILE "/40103 SET TIME_ZONE=@OLD_TIME_ZONE/" {*}
  mv ${FILE}1 foot
fi

for FILE in `ls -1 table*`; do
  NAME=`head -n1 $FILE | cut -d$'\x60' -f2`
  cat head $FILE foot > "$NAME.sql"
done

rm head foot table*
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top