Skip to content

Instantly share code, notes, and snippets.

@onigra
Created May 30, 2013 04:11
Show Gist options
  • Save onigra/5675674 to your computer and use it in GitHub Desktop.
Save onigra/5675674 to your computer and use it in GitHub Desktop.
スキーマに登録されてるテーブルをdumpする
#!/bin/bash
schema_name="hoge"
for x in `mysql -N -u user -ppass -e "select TABLE_SCHEMA || '@' || TABLE_NAME from information_schema.tables where TABLE_SCHEMA = '${schema_name}';"`;
do
table_name=`echo ${x} | cut -d@ -f2`;
mysqldump -t -u user -ppass -w"last_update >= '2013-05-01 00:00:00'" --add-drop-table=false --insert-ignore ${_schema_name} ${_table_name} > ${_table_name}.sql
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment