使うケースが出た時点で100%トラブルですが、MySQLは条件を指定してDUMPをおこなうことができます。
画面上でデータを確認しつつダンプする方法です。
function selectAndDump() {
table=$1
criteria=$2
uniquekey=$3
columns=$4
localtmp=`mktemp`
if [ "$columns" = "" ]; then
echo "select * from $table where $criteria ;"
mysql -uroot -D${DB} -t -e "select * from $table where $criteria ;" | tee $localtmp
else
echo "select ${columns} from $table where $criteria ;"
mysql -uroot -D${DB} -t -e "select ${columns} from $table where $criteria ;" | tee $localtmp
fi
if [ `cat $localtmp | wc -l` -ne 0 ]; then
mysqldump -uroot ${DB} -t $table --where "${criteria}" > ${OUTDIR}/${table}_${uniquekey}.dump
fi
rm -f $localtmp
}
selectAndDump "project" "project_id = $projectId" "$projectId"
selectAndDump "file" "file_id in ($FILEIDS)" "$KEY" "file_id, name, content_type, update_date"


