#!/bin/csh -f # dbsave # ----------------------------------------------------------------------------- # C shell script to dump data from the HHL MySQL DB. # ----------------------------------------------------------------------------- # Revision History: # $Log$ # ----------------------------------------------------------------------------- if ($1 == "-?" || $1 == "-h" || $1 == "help") then set verb = $0 echo "Usage: $verb:t" echo "Usage: $verb:t table_name" exit 1 endif #set echo mysqldump -u root \ -p${MYSQL_PW} \ --order-by-primary # Sorted is easier to diff w/other dumps \ --complete-insert # Include column names in INSERTS \ --opt # Default. Useful set of default options: \ # --add-drop-table \ # --add-locks \ # --create-options \ # --disable-keys \ # --extended-insert (overridden below) \ # --lock-tables \ # --quick \ # --set-charset \ --add-drop-table # Default. Harmless since we expect to \ # only run on dropped DB anyhow, for now. \ --add-locks # Default. Faster loads \ --create-options # Default. MySQL-specific table options. \ --disable-keys # Default. Disable keys while loading \ --skip-extended-insert # Only one DB row per INSERT \ --lock-tables # Default. Lock all tables for data \ # consistency in dump file. \ --quick # Don't try to buffer entire table in RAM \ --databases # CREATE DATABASE and USE. Also DROP \ # DATABASE if --add-drop-database. \ # Better to omit USE so that the dump file \ # can be used to create a DB with a \ # different name for testing/debugging \ # purposes? No. We need the DROP DATABASE\ # below, so we may as well keep the USE. \ --add-drop-database # Safer to require manual drop? No. \ # Decided we have to drop the entire DB to \ # go safely back to a previous DB version \ # where a table never existed. Otherwise, \ # the dump file contains DROP TABLE for \ # all of the previous tables that we are \ # restoring, but not for the newer tables \ # that we are reverting from. So, after \ # reverting to a previous DB, the newer \ # tables still exist, and the next attempt \ # to migrate forward to the newer DB \ # complains about trying to create a table \ # that already exists. \ # Other reasonable choice is to omit DROP \ # DATABASE, CREATE DATABASE, and USE, and \ # remind users to always do a manual DROP \ # and CREATE. Seems tedious. Better to \ # require occasional user who wants to use \ # a different DB name to edit the dump \ # file before loading it. \ --dump-date # Show date/time as a comment. Change to \ # --skip-dump-date for identical diffs of \ # dump files. \ --skip-no-create-info # Default. Do want CREATE TABLEs \ --skip-no-data # Default. Do want INSERTs \ --routines # Stored procedures and functions, if any \ --triggers # Triggers, if any \ hhlwebdb #echo "Don't forget to also save the external image and other files."