Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Database parameters
- #schema which we want to export
- dbnamePROD=crm
- #schema onto which we want to import an existing database
- dbnameDEV=affise
- dbUser=root
- dbPassword=123bnm$S
- #filename with current timestamp
- filenameDump="prod-dump-$(date '+%Y-%m-%d_%H-%M-%S').sql"
- echo "Export $dbnamePROD database"
- echo "start $(date '+%H-%M-%S')"
- mysqldump "$dbnamePROD" -h 138.68.99.26 -u "$dbUser" --password="$dbPassword" > "$filenameDump" --disable-keys --extended-insert --no-create-db --skip-add-locks --skip-set-charset
- echo "end $(date '+%H-%M-%S')"
- echo
- echo "running queries at $dbnameDEV database"
- echo "start $(date '+%H-%M-%S')"
- mysql -u $dbUser -p$dbPassword -e "
- DROP DATABASE IF EXISTS $dbnameDEV;
- CREATE DATABASE $dbnameDEV;
- USE $dbnameDEV;
- source $filenameDump;"
- echo "end $(date '+%H-%M-%S')"
- echo
- echo "migrating, cleaning cache"
- php bin/console --no-interaction doctrine:migrations:migrate
- php bin/console cache:clear
- php bin/console cache:warmup
- #delete dump
- #in future,we may replace old dump with new one for purpose of downloading current dump via ftp to create a local sandbox
- #but currently deleting present file is all we need
- rm $filenameDump
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement