Guest User

Untitled

a guest
Jul 11th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. echo "Generate dump?(yes)"
  4. read godump
  5. if [ $godump = 'yes' ] || [ $godump = 'y' ]; then
  6.  
  7.  
  8. read -p "mysql user: " YOUR_USER
  9. read -p "mysql password: " YOUR_PASSWORD
  10. read -p "mysql host: " YOUR_HOST
  11. read -p "mysql database: " YOUR_DB
  12. read -p "output file: " YOUR_OUTPUT_FILE
  13.  
  14.  
  15. echo "DUMP =================================================================================="
  16. echo "dumping database.."
  17. mysqldump -h $YOUR_HOST -u $YOUR_USER -p$YOUR_PASSWORD --ignore-table=$YOUR_DB.log_customer --ignore-table=$YOUR_DB.log_visitor --ignore-table=$YOUR_DB.log_visitor_info --ignore-table=$YOUR_DB.log_url --ignore-table=$YOUR_DB.log_url_info --ignore-table=$YOUR_DB.log_quote --ignore-table=$YOUR_DB.report_viewed_product_index --ignore-table=$YOUR_DB.report_compared_product_index --ignore-table=$YOUR_DB.report_event --ignore-table=$YOUR_DB.catalog_compare_item --opt $YOUR_DB | gzip > $YOUR_OUTPUT_FILE.sql.gz
  18. sed -i 's/DEFINER=[^*]*\*/\*/g' $YOUR_OUTPUT_FILE.sql.gz
  19. echo "dump created"
  20.  
  21. echo "--------------------------------------------"
  22. echo "Generate tar from dump?(yes)"
  23. read choice
  24. if [ $choice = 'yes' ] || [ $choice = 'y' ]; then
  25. echo "generating tar"
  26. tar -czvf YOUR_OUTPUT_FILE.tar.gz $YOUR_OUTPUT_FILE.sql.gz
  27. echo "tar created"
  28. fi
  29. choice="";
  30. fi
  31.  
  32.  
  33. echo "LOCAL OPTIONS =================================================================================="
  34. echo "Local database changes(import, update site url, change admin user password)?(yes)"
  35. read choice
  36. if [ $choice = 'yes' ] || [ $choice = 'y' ]; then
  37. read -p "mysql user: " user
  38. read -p "mysql password: " password
  39. read -p "mysql host: " host
  40. read -p "mysql database: " database
  41.  
  42.  
  43. echo "--------------------------------------------"
  44. echo "Import to local database from file?(yes)"
  45. read choice
  46. if [ $choice = 'yes' ] || [ $choice = 'y' ]; then
  47. read -p "file to import: " YOUR_OUTPUT_FILE
  48. echo "importing database..."
  49.  
  50. #mysql -h $host -u $user -$password -D $database -e "DROP DATABASE IF EXISTS $database;"
  51. mysql -h $host -u $user -p$password -e "CREATE DATABASE IF NOT EXISTS $database;"
  52. mysql -h $host -u $user -p$password -D $database < $YOUR_OUTPUT_FILE
  53. echo "import success"
  54. fi
  55. choice="";
  56.  
  57. echo "--------------------------------------------"
  58. echo "Update site URLs?(yes)"
  59. read choice
  60. if [ $choice = 'yes' ] || [ $choice = 'y' ]; then
  61. read -p "new site url: " local_url
  62. echo "updating..."
  63. mysql -h $host -u $user -p$password -D $database -e "update core_config_data set value = '$local_url' where path = 'web/unsecure/base_url'";
  64. mysql -h $host -u $user -p$password -D $database -e "update core_config_data set value = '$local_url' where path = 'web/secure/base_url'";
  65. echo "done"
  66. fi
  67. choice="";
  68.  
  69. echo "--------------------------------------------"
  70. echo "Update cookie domain?(yes)"
  71. read choice
  72. if [ $choice = 'yes' ] || [ $choice = 'y' ]; then
  73. read -p "cookie domain: " local_url
  74. echo "updating..."
  75. mysql -h $host -u$user -p$password -D $database -e "update core_config_data set value='$local_url' where path='web/cookie/cookie_path' and value is not null";
  76. echo "done"
  77. fi
  78. choice="";
  79.  
  80. echo "--------------------------------------------"
  81. echo "Change admin user password?(yes)"
  82. read choice
  83. if [ $choice = 'yes' ] || [ $choice = 'y' ]; then
  84. read -p "user name: " user_name
  85. read -p "new password: " new_password
  86. echo "updating..."
  87. mysql -h$host -u$user -p$password -D$database -e "UPDATE admin_user SET password = MD5('$new_password') WHERE username = '$user_name'";
  88. echo "done"
  89. fi
  90. choice="";
  91.  
  92. fi
Add Comment
Please, Sign In to add comment