#!/bin/bash RHOST=root@35.156.160.20 HOST=db-2m2-2.c8gu5lmtuiqq.eu-central-1.rds.amazonaws.com USER=m2user PASS="g37gjhjkm29pf" DB=m2db ARG_MAX=`ssh $RHOST 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 = '$DB' and table_type != 'VIEW'" | ssh $RHOST mysql -N -h$HOST -u$USER -p"$PASS" $DB` ssh $RHOST mysqldump -h$HOST -u$USER -p"$PASS" -Q --hex-blob -n --skip-routines --skip-triggers $DB $TABLES | grep -v -P "50013 DEFINER=.+SQL SECURITY DEFINER"