Created
February 19, 2018 18:09
-
-
Save xlbruce/992e60dc82cd8a0b84fd517dda30165a to your computer and use it in GitHub Desktop.
This script makes a dump from a given database ignoring unwanted content from certain tables, like histories and orders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| tmpFile1=~/.tmp1$$ | |
| tmpFile2=~/.tmp2$$ | |
| database=$1 | |
| database_local=$2 | |
| function cleanFiles() { | |
| rm $tmpFile1 $tmpFile2 > /dev/null 2>&1; | |
| exit; | |
| } | |
| function parseArgs() { | |
| if [[ -z $database ]]; then | |
| echo "Database name must be specified"; | |
| exit 1; | |
| fi | |
| } | |
| trap cleanFiles SIGINT SIGTERM; | |
| parseArgs; | |
| mysqldump --no-data -h phoenix-db-qa.clickbus.net -u $user -p $password $database \ | |
| client_communication \ | |
| customer \ | |
| log_route \ | |
| order_item_payment_status_history \ | |
| order_item_status_history \ | |
| order_status_history \ | |
| payment_configuration_cc_history \ | |
| payment_configuration_history \ | |
| payment_gateway_config_card_brand_history \ | |
| payment_gateway_config_history \ | |
| service_fee_configuration_history \ | |
| seat_block \ | |
| trip \ | |
| trip_booking_engine \ | |
| trip_metadata \ | |
| --lock-tables=false \ | |
| --ignore-table=$database.city_summary \ | |
| --ignore-table=$database.order_summary \ | |
| --ignore-table=$database.place_summary \ | |
| --ignore-table=$database.trip_reference_price_summary \ | |
| --ignore-table=$database.travel_company_summary \ | |
| --ignore-table=$database.travel_company_summary > $tmpFile1 2> /dev/null & | |
| mysqldump -h phoenix-db-qa.clickbus.net -u $user -p $password $database \ | |
| --ignore-table=$database.client_communication \ | |
| --ignore-table=$database.customer \ | |
| --ignore-table=$database.log_route \ | |
| --ignore-table=$database.order_item_payment_status_history \ | |
| --ignore-table=$database.order_item_status_history \ | |
| --ignore-table=$database.order_status_history \ | |
| --ignore-table=$database.payment_configuration_cc_history \ | |
| --ignore-table=$database.payment_configuration_history \ | |
| --ignore-table=$database.payment_gateway_config_card_brand_history \ | |
| --ignore-table=$database.payment_gateway_config_history \ | |
| --ignore-table=$database.service_fee_configuration_history \ | |
| --ignore-table=$database.seat_block \ | |
| --ignore-table=$database.seat_block_metadata \ | |
| --ignore-table=$database.trip \ | |
| --ignore-table=$database.trip_booking_engine \ | |
| --ignore-table=$database.trip_metadata \ | |
| --lock-tables=false \ | |
| --ignore-table=$database.city_summary \ | |
| --ignore-table=$database.order_summary \ | |
| --ignore-table=$database.place_summary \ | |
| --ignore-table=$database.trip_reference_price_summary \ | |
| --ignore-table=$database.travel_company_summary \ | |
| --ignore-table=$database.travel_company_summary > $tmpFile2 2> /dev/null & | |
| wait; | |
| cleanFiles; | |
| mysql -uroot $database_local < $tmpFile1 | |
| mysql -uroot $database_local < $tmpFile2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment