How to export each tables from a database into a separate files using mysqldump command

How to export each tables from a database into separate files using mysqldump command. Create a script file, and put the below content into it.


  #!/bin/bash 
  T_PATH=Downloads/tables_templates
  for TB in `mysql -u root -proot -N -B -e 'show tables from drupal'`;
  do
  echo "Backing up $TB"
  mysqldump --add-drop-table --add-locks --complete-insert -u root -proot drupal $TB > $T_PATH/template_$TB.sql
  

Where T_PATH is location of the file where script will export the table. and TB is a reference to the current value of show tables command.

Comments

Popular posts from this blog

How to setup Drupal 8 Multisite on nginx webserver with different domain.

Install drush globally using composer on WSL

Drupal views create exposed filter programmatically