Guest User

Untitled

a guest
Mar 11th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. #  Attempt to migrate site from Server A to Server B
  4. #   Requires SSH-Key installed for Server A on Server B
  5. #
  6. #
  7.  
  8. # @todo: Setup the if statement for command line arguments.
  9. siteName='blogusage.com' # @ todo get this from cli args
  10. pullSQL=true
  11. phpFPMConnections=5
  12. remoteDBUsername='migtest'
  13. remoteDBPassword='migtest'
  14. localDBUsername=''
  15. localDBPassword=''
  16. hasSSL=false
  17.  
  18. mysqlDumpQuery="mysqldump --add-drop-database --add-drop-table --extended-insert --no-create-info --skip-comments -Q -u${remoteDBUsername} -p${remoteDBPassword} "
  19.  
  20. IFS='
  21. '
  22.  
  23. #@todo have to figure out how to connect to get a database dump...command over ssh?
  24. userDatabases=`mysql -u${remoteDBUsername} -p${remoteDBPassword} <<QUERY_INPUT
  25. select schema_name from information_schema.schemata WHERE schema_name NOT IN ('information_schema', 'mysql', 'performance_schema', 'test');
  26. QUERY_INPUT`
  27.  
  28. cnt=${#userDatabases[*]}
  29. for ((i=1; i<$cnt; i++))
  30. do
  31.     echo ${mysqlDumpQuery}
  32.  
  33.     `${mysqlDumpQuery} ${userDatabases[i]} > ${siteName}_${userDatabases[i]}`
  34.     gzip ${siteName}_${userDatabases[i]}
  35.    
  36.     echo ${userDatabases[i]}
  37. done
Add Comment
Please, Sign In to add comment