Advertisement
Guest User

Untitled

a guest
May 6th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Database parameters
  4.  
  5. #schema which we want to export
  6. dbnamePROD=crm
  7.  
  8. #schema onto which we want to import an existing database
  9. dbnameDEV=affise
  10.  
  11. dbUser=root
  12. dbPassword=123bnm$S
  13.  
  14. #filename with current timestamp
  15. filenameDump="prod-dump-$(date '+%Y-%m-%d_%H-%M-%S').sql"
  16.  
  17. echo "Export $dbnamePROD database"
  18.  
  19. echo "start $(date '+%H-%M-%S')"
  20. 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
  21. echo "end $(date '+%H-%M-%S')"
  22. echo
  23.  
  24. echo "running queries at $dbnameDEV database"
  25.  
  26. echo "start $(date '+%H-%M-%S')"
  27. mysql -u $dbUser -p$dbPassword -e "
  28. DROP DATABASE IF EXISTS $dbnameDEV;
  29. CREATE DATABASE $dbnameDEV;
  30. USE $dbnameDEV;
  31. source $filenameDump;"
  32. echo "end $(date '+%H-%M-%S')"
  33. echo
  34.  
  35. echo "migrating, cleaning cache"
  36.  
  37. php bin/console --no-interaction doctrine:migrations:migrate
  38. php bin/console cache:clear
  39. php bin/console cache:warmup
  40.  
  41. #delete dump
  42.  
  43. #in future,we may replace old dump with new one for purpose of downloading current dump via ftp to create a local sandbox
  44. #but currently deleting present file is all we need
  45. rm $filenameDump
  46. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement