#!/bin/bash RHOST=root@m2realty.dev.orange35.com HOST=m2dbinstance.cpp9olmcwlga.eu-central-1.rds.amazonaws.com USER=m2user PASS="djhkkll34o9dD#s2^aqw" 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` NOW=$(date +"%Y-%m-%d-%H-%M-%S") FILENAME="$NOW-m2db.sql" ssh $RHOST mysqldump -h$HOST -u$USER -p"$PASS" -Q --hex-blob -n --skip-routines --skip-triggers "${@: 2}" $DB $TABLES | grep -v -P "50013 DEFINER=.+SQL SECURITY DEFINER" > $FILENAME