Advertisement
Guest User

Untitled

a guest
Mar 17th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. echo -n "Enter the Database: "
  4. read database
  5.  
  6. echo -n "Enter the User: "
  7. read user
  8.  
  9. echo -n "Enter the Password: "
  10. read password
  11.  
  12. echo -n "Enter Website ID: "
  13. read website_id
  14.  
  15. params="--user=${user} --databases ${database} --password=${password} --compact --single-transaction=TRUE --debug-info --debug-check --skip-lock-tables"
  16.  
  17. tables=("product_specification" "rmi_stage" "users" "brands" "categories" "product_groups" "company_packages" "companies" "industries" "server")
  18.  
  19. table_website=("website_products" "website_product_view" "product_specification_rmi" "product_images" "website_allowed_brands" "products" "analytics_craigslist" "index_products" "website_product_groups" "products_rmi" "website_brand_category" "website_users" "website_categories" "ratings" "website_product_ashley_express" "website_settings" "website_files" "website_notes" "website_pages" "website_product_options" "website_product_option_list_items" "website_blocked_category" "auth_user_websites" "website_top_brands" "website_auto_price" "website_industries" "websites" "website_location" "website_passwords" "website_shipping_methods" "product_options" "website_coupons" "website_brands" "mobile_pages" "website_sm_account" "product_import" "website_product_shipping_method")
  20. query_website="website_id=${website_id}"
  21.  
  22. table_website_reach=("website_reach_meta" "website_reaches" "website_reach_comments")
  23. query_website_reach="website_reach_id in (select website_reach_id from website_reaches where ${query_website})"
  24.  
  25. table_product=("product_images_rmi" "product_group_relations")
  26. query_product="product_id in (select product_id from products where ${query_website})"
  27.  
  28. table_product_option=("product_option_relations" "product_option_list_items")
  29. query_product_option="product_option_id in (select product_option_id from product_options where ${query_website})"
  30.  
  31. table_website_page=("website_attachments" "website_pagemeta")
  32. query_website_PAGE="website_page_id in (select website_page_id from website_pages where ${query_website})"
  33.  
  34. table_where=("website_product_group_relations" "attribute_item_relations")
  35. conds_where=("website_product_group_id in (select website_product_group_id from website_product_groups where ${query_website})" "product_id in (select product_id from website_products where ${query_website})")
  36.  
  37. mysqldump ${params} --no-data >> ./schema.sql
  38.  
  39. for i in "${tables[@]}"
  40. do
  41. mysqldump ${params} --no-create-db --no-create-info --tables ${tables[$i]} >> ./data.sql
  42. done
  43.  
  44. for i in "${table_website[@]}"
  45. do
  46. mysqldump ${params} --no-create-db --no-create-info --tables ${table_website[$i]} --where="${query_website}" >> ./data.sql
  47. done
  48.  
  49. for i in "${table_website_reach[@]}"
  50. do
  51. mysqldump ${params} --no-create-db --no-create-info --tables ${table_website_reach[$i]} --where="${query_website_reach}" >> ./data.sql
  52. done
  53.  
  54. for i in "${table_product[@]}"
  55. do
  56. mysqldump ${params} --no-create-db --no-create-info --tables ${table_product[$i]} --where="${query_product}" >> ./data.sql
  57. done
  58.  
  59. for i in "${table_product_option[@]}"
  60. do
  61. mysqldump ${params} --no-create-db --no-create-info --tables ${table_product_option[$i]} --where="${query_product_option}" >> ./data.sql
  62. done
  63.  
  64. for i in "${table_where[@]}"
  65. do
  66. mysqldump ${params} --no-create-db --no-create-info --tables ${table_where[$i]} --where="${conds_where[$i]}" >> ./data.sql
  67. done
  68.  
  69. gzip -9 schema.sql
  70. gzip -9 data.sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement