Advertisement
Guest User

Untitled

a guest
May 6th, 2015
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #/usr/bin/env sh
  2.  
  3. # must match the server name in ~/.ssh/config if the specified settings are to be used
  4. SOURCE_SSH_SERVER=lutra
  5.  
  6. # username for the target mysql
  7. MYSQL_USER=root
  8.  
  9. # password for the target mysql
  10. MYSQL_PASS=pass
  11.  
  12. # hostname of the target mysql
  13. MYSQL_HOST=127.0.0.1
  14.  
  15.  
  16.  
  17. if [ $# != 3 ]; then
  18. echo "
  19. This script is used to get a mysql database dump from a remote server and send it to another myslq instance.
  20.  
  21. USAGE
  22. It takes three arguments:
  23. dbname The name of the source db
  24. username The username to access the source db
  25. password The password to access the source db
  26.  
  27. EXAMPLE
  28. sh mysqlDbImporter.sh dbname username password
  29. "
  30. exit 0
  31. fi
  32.  
  33. ssh $SOURCE_SSH_SERVER mysqldump \
  34. --databases \
  35. --add-drop-database \
  36. -u $2\
  37. -p$3 \
  38. $1 | mysql -u $MYSQL_USER -p$MYSQL_PASS -h $MYSQL_HOST
  39. echo "Database $1 has been imported."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement