#!/bin/tcsh # First grab the bulk of the tables. Skip the big ones. (mysqldump --no-data -uroot -pxxx123 -hpablo mydb alerts alerts_daily candles_5m candles_d; mysqldump --opt --single-transaction --master-data -u root -pxxx123 -h wally-balls mydb `mysql -u root -pxxx123 -e "SHOW TABLES" -h wally-balls mydb | grep -v '^\(alerts\|candles\)' | grep -v Tables_in_mydb`)|gzip -1 > /tmp/main_mydb.sql.gz # Now grab the smaller parts of the big data mysqldump -uroot -pxxx123 -hpablo --opt --single-transaction --skip-add-locks mydb alerts_daily candles_5m candles_d | gzip -1 > /tmp/big_mydb.sql.gz # Finally, split the alerts into different tasks. Respect the same caching rules as the alerts server. ./backup_helper.tcl # notice the following options to mysqldump # # --no-data - We always start with the shell of the big tables. That is # espeically necessary for the alerts table because of the way we # save and restore that data. # --opt - This seems to be a default now. In the old days you would crash if # you tried to dump a big table without this. # --single-transaction - This is *not* optional. It is required for use with # --master-data and it is required because the default # type of locking would lock up the server for too long. # --master-data - This is not present in old versions of mysql. (Drama does # not have this, but luckily it is a feature of the client # not the server.) This is the only reasonable way to copy # data to a slave. # --skip-add-locks - By default the program will lock the table before it # starts restoring the data, and unlocks it at the end. # Among other things, this is supposed to give you a little # speed. I avoid that for the big tables. Without the # locks, I can check the status of the table with statements # like SELECT COUNT(*) or SELECT MAX(id). # --no-create-info - I use this on the alerts table because we split it up into # several pieces. Otherwise each time you started a new # piece, it would overwrite the old ones, rather than adding # to what we already have. # Note: You need to start restoring main_mydb.sql.gz before you restore any of the # other files. The beginning of main_mydb.sql.gz includes the table definitions for # some of the other files. If you try to restore two files at once, each will run # at approximately the same speed as if they were one at a time, doubling the speed of # the entire operation. If you try to restore more than two files at a time, you will # quickly run into diminishing returns.