1. Скрипт синхронизации базы продакшена на дев сервер.

#!/bin/bash

_mysql="/usr/bin/mysql"
_mysqldump="/usr/bin/mysqldump"
_gzip="/bin/gzip"
_rm="/bin/rm"
_zcat="/bin/zcat"                                                                  
      

for db in "<db1>" "<db2>"; do                                                  
if [ -a /root/$db-prod.sql.gz ] then
${_rm} /root/$db-prod.sql.gz
fi
${_mysqldump} -h <host> -u <user> -p<password> \
--lock-tables=false $db | ${_gzip} > /root/$db-prod.sql.gz
if [ -a /root/$db-dev.sql.gz ] then
${rm} /root/$db-dev.sql.gz
fi
${_mysqldump} $db | ${_gzip} > /root/$db-dev.sql.gz
${_mysql} -e "drop database $db; create database $db;"
${_zcat} /root/$db-prod.sql.gz | ${_mysql} $db
done
exit

==================================================================

2. Скрипт выкатки баз из бекапа:

#!/bin/bash

pushd /var/backup/remote_nfs/databases_adm1/sql_dumps/  > /dev/null

for i in db1 db2 db3 db4 db5 db6 another_db ;
do
db_file=`find . -name "$i*" -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" " | cut -f2- -d"/"`;
db_name=`echo $db_file | awk -F- '{print $1}'`;
echo "$(date): Deploing $db_file -> $db_name"
zcat $db_file | mysql $db_name ;
done

popd  > /dev/null