#!/bin/bash HOST=catzilla USER=dev PASS=devpass ARG_MAX=`getconf ARG_MAX` TABLES=`echo "set @@group_concat_max_len=$ARG_MAX; select group_concat(table_name separator ' ') from information_schema.tables where table_schema = '$1' and table_type != 'VIEW'" | mysql -N -h$HOST -u$USER -p$PASS $1` NOW=$(date +"%Y-%m-%d-%H-%M-%S") FILENAME="$NOW-$1.sql" mysqldump -h$HOST -u$USER -p$PASS -Q --hex-blob -n --skip-routines --skip-triggers "${@: 2}" $1 $TABLES | grep -v -P "50013 DEFINER=.+SQL SECURITY DEFINER" > $FILENAME