2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mysqldumpで複数テーブルを除外する方法

Posted at

手打ち

一つ二つだったら良いけど十個もあるととても面倒です。そして長いから汚いです。

mysqldump -u root -p password --ignore-table=dbname.tbl1 --ignore-table=dbname.tbl2 .... dbname | gzip -c > dbname.sql.gz

bashのforを使ってみた

#!/usr/bin/env bash

TABLES=("tbl1" "tbl2" "tbl3" "tbl4" "tbl5" ... "tbl100")
IGNORE_TABLES=""
for X in ${TABLES[@]}; do
  IGNORE_TABLES=$IGNORE_TABLES" --ignore-table=dbname.${TBL}"
done

mysqldump -u root -p password ${IGNORE_TABLES} dbname | gzip -c > dbname.sql.gz

多分これで動くはず。

2
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?