Posted By

1b0t on 09/24/09


Tagged

mysql Bash backup loop


Versions (?)

insert backed up dumps from mysql


 / Published in: Bash
 

  1. #!/bin/sh
  2. # creates and fills mysql databases from a directory
  3. # of sql-files named like database.sql
  4.  
  5. for i in `ls -1 $1`;
  6. do
  7. db_name=`echo $i|cut -d'.' -f1`;
  8. cmd="create database $db_name;";
  9. echo will exec: $cmd;
  10. mysql -uroot -p$2 -e "$cmd";
  11. mysql -uroot -p$2 $db_name<$1$i;
  12. done

Report this snippet  

You need to login to post a comment.