mysql

Extract one database from mysql/mariadb full dump

Submitted by Fekete Zoltán on Thu, 07/26/2018 - 13:51

Save this script into an sh file:

#!/usr/bin/env bash

DBNAME=$1
INFILE=$2

SED_FILTER="/^-- Current Database: \`$DBNAME\`/,/^-- Current Database: /p"

sed -n "$SED_FILTER" $INFILE > $DBNAME.sql

echo "Dump is ready: $DBNAME.sql"

exit 0


Run as :

$ sh script_name dbname full_dump_file