Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- echo -n "Enter the Database: "
- read database
- echo -n "Enter the User: "
- read user
- echo -n "Enter the Password: "
- read password
- echo -n "Enter Website ID: "
- read website_id
- params="--user=${user} --databases ${database} --password=${password} --compact --single-transaction=TRUE --debug-info --debug-check --skip-lock-tables"
- tables=("product_specification" "rmi_stage" "users" "brands" "categories" "product_groups" "company_packages" "companies" "industries" "server")
- 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")
- query_website="website_id=${website_id}"
- table_website_reach=("website_reach_meta" "website_reaches" "website_reach_comments")
- query_website_reach="website_reach_id in (select website_reach_id from website_reaches where ${query_website})"
- table_product=("product_images_rmi" "product_group_relations")
- query_product="product_id in (select product_id from products where ${query_website})"
- table_product_option=("product_option_relations" "product_option_list_items")
- query_product_option="product_option_id in (select product_option_id from product_options where ${query_website})"
- table_website_page=("website_attachments" "website_pagemeta")
- query_website_PAGE="website_page_id in (select website_page_id from website_pages where ${query_website})"
- table_where=("website_product_group_relations" "attribute_item_relations")
- 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})")
- mysqldump ${params} --no-data >> ./schema.sql
- for i in "${tables[@]}"
- do
- mysqldump ${params} --no-create-db --no-create-info --tables ${tables[$i]} >> ./data.sql
- done
- for i in "${table_website[@]}"
- do
- mysqldump ${params} --no-create-db --no-create-info --tables ${table_website[$i]} --where="${query_website}" >> ./data.sql
- done
- for i in "${table_website_reach[@]}"
- do
- mysqldump ${params} --no-create-db --no-create-info --tables ${table_website_reach[$i]} --where="${query_website_reach}" >> ./data.sql
- done
- for i in "${table_product[@]}"
- do
- mysqldump ${params} --no-create-db --no-create-info --tables ${table_product[$i]} --where="${query_product}" >> ./data.sql
- done
- for i in "${table_product_option[@]}"
- do
- mysqldump ${params} --no-create-db --no-create-info --tables ${table_product_option[$i]} --where="${query_product_option}" >> ./data.sql
- done
- for i in "${table_where[@]}"
- do
- mysqldump ${params} --no-create-db --no-create-info --tables ${table_where[$i]} --where="${conds_where[$i]}" >> ./data.sql
- done
- gzip -9 schema.sql
- gzip -9 data.sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement