Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --fields-terminated-by=name
- Fields in the output file are terminated by the given
- --lines-terminated-by=name
- Lines in the output file are terminated by the given
- `--fields-terminated-by`
- MYSQL_USER=root
- MYSQL_PASS=rootpassword
- MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}"
- SQLSTMT="SELECT CONCAT(table_schema,'.',table_name)"
- SQLSTMT="${SQLSTMT} FROM information_schema.tables WHERE table_schema NOT IN "
- SQLSTMT="${SQLSTMT} ('information_schema','performance_schema','mysql')"
- mysql ${MYSQL_CONN} -ANe"${SQLSTMT}" > /tmp/DBTB.txt
- COMMIT_COUNT=0
- COMMIT_LIMIT=10
- for DBTB in `cat /tmp/DBTB.txt`
- do
- DB=`echo "${DBTB}" | sed 's/./ /g' | awk '{print $1}'`
- TB=`echo "${DBTB}" | sed 's/./ /g' | awk '{print $2}'`
- DUMPFILE=${DB}-${TB}.csv.gz
- mysqldump ${MYSQL_CONN} --fields-terminated-by="t" --lines-terminated-by="rn" ${DB} ${TB} | gzip > ${DUMPFILE}
- (( COMMIT_COUNT++ ))
- if [ ${COMMIT_COUNT} -eq ${COMMIT_LIMIT} ]
- then
- COMMIT_COUNT=0
- wait
- fi
- done
- if [ ${COMMIT_COUNT} -gt 0 ]
- then
- wait
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement