Page 1 of 1

how to split a particular database from single database dump

Posted: Tue Dec 04, 2012 5:11 pm
by a24uall
serve.full-databases.sql is the full database dump file name
aaron_jo151 Is the database name that I want to restore
First find the line number where the database backups start. below command will help you in that :
grep -n "Current Database" serve.full-databases.sql
where serve.full-databases.sql is the name of the full sql dump that we created

In the current example I need a database named "aaron_jo151" restored. So the above command gave me the line numbers as below (Pasting just the relevant part below)
627924:-- Current Database: `aasal_data`
628152:-- Current Database: `aaron_jo151`
631024:-- Current Database: `bafu_jo151`
sed -n '628152,631024p' serve7.all-databases.sql > aaron_newbackup.sql
--
-- Table structure for table `jos_banner`
--
LOCK TABLES `jos_weblinks` WRITE;
/*!40000 ALTER TABLE `jos_weblinks` DISABLE KEYS */;
/*!40000 ALTER TABLE `jos_weblinks` ENABLE KEYS */;
UNLOCK TABLES;