To synchronize with the master database:

1) Back up your database in case the pre-synchronization steps do something
   horribly wrong -- I've tested them as well as I could, but you may
   discover that they do something unexpected, so better safe than sorry.

   For mysql, you can do this by running

     mysqldump --quick --add-drop-table -p domprodtest > dpt.dump

   and entering your password when prompted.  Note that the database
   can be HUGE, so make sure you've got enough diskspace.  You can
   compress the dump by piping it to 'bzip2 -c' or 'gzip -c':

     mysqldump --quick --add-drop-table -p domprodtest | bzip2 -c > dpt.dump

2) daq-db-sync contains two utilities to clean up the database:

   * FindDupProds finds duplicate or unreferenced Product and/or
     Assembly rows
   * FindOrphans finds references to nonexistent IDs in the database

   By default, these programs don't make any changes to the database.  You
   must specify the '-d' option to have them make changes to the database.
   These programs can also be run with the '-v' option to provide a
   description of the actions each program is taking.

   If you'd like to see what actions these programs will take, you can
   run them as 'java icecube.daq.db.app.FindDupProds -v' and
   'java -Xmx512m icecube.daq.db.app.FindOrphans -v'.  (Note that
   FindOrphans can use up a LOT of memory, so '-Xmx512m' is used to
   make sure it has enough room to work.)

   Once you're confident that the programs won't do any harm, run
   'java icecube.daq.db.app.FindDupProds -v -d' and
   'java icecube.daq.db.app.FindOrphans -v -d'.  This first pass may cause
   other unreferenced rows to be exposed, so you should rerun both programs
   until no more duplicate/unreferenced rows are found.

   There are situations which these programs cannot handle, so you may need
   to delete some Assembly rows by hand.  If you're not comfortable doing
   this, please contact dglo@icecube.wisc.edu

3) Add a master entry to your domprodtest.properties file.  Currently
   we are synchronizing with glacier.lbl.gov, but this will change to
   a master machine in icecube.wisc.edu at some point:

      database.master.driver: org.gjt.mm.mysql.Driver
      database.master.url: jdbc:mysql://glacier.lbl.gov/domprodtest
      database.master.user: XXX
      database.master.password: YYY

4) The Sync application is used to synchronize the local database with the
   master database.  Unlike the FindDupProds and FindOrphans applications,
   the Sync application makes changes to the database by default. If you'd
   like to see what would be done without any changes being made to the
   database, run 'java icecube.daq.db.app.Sync -v -t'.

   Once you're ready to synchronize the local database, run
   'java icecube.daq.db.app.Sync -v'.

5) Run 'java icecube.daq.db.app.Sync -v' again.  There should be no
   output.  If there is, it will likely fall into one of the following
   classes:

  a) == Missing table "XXX"
     This indicates a table which is present in the master database
     but is missing in the local database.  You should probably add
     the specified table.
  b) == Extra table "XXX"
     This indicates a table which is present in the local database
     but is missing in the master database.  If this is to be used in
     a project-wide program, you should notify dglo@icecube.wisc.edu
  c) == master.XXX does not match local.XXX
     This indicates that the master table is somehow different from the
     local table.  You should probably dump the local table, recreate the
     table using the master description, and then reload the local data
  d) == Missing index "YYY" on XXX
     This indicates an index which is present in the master database
     but is missing in the local database.  You should probably create
     the specified index.
  e) == Extra index "YYY" on XXX
     This indicates an index which is present in the local database
     but is missing in the master database.  If this not intended only
     for local use, you should notify dglo@icecube.wisc.edu
  f) == master.XXX index "YYY" does not match local.XXX index "YYY"
     This indicates that the master index is somehow different from the
     local index.  You should probably drop the local index and create
     the master index.

6) Add 'java icecube.daq.db.app.Sync -v' as a cron job which is run every
   night, so that your database continues to stay synchronized.
