1fbf0a4bf3e1a40b9a117893d61b395561779d7a
chmalee
  Mon Sep 23 13:45:20 2019 -0700
Adding archiving commands to otto build scripts, refs #21825

diff --git src/hg/utils/otto/omim/checkOmim.sh src/hg/utils/otto/omim/checkOmim.sh
index 160809f..9d435fb 100755
--- src/hg/utils/otto/omim/checkOmim.sh
+++ src/hg/utils/otto/omim/checkOmim.sh
@@ -70,28 +70,44 @@
   ln -s ../mim2gene.txt ./mim2gene.txt
   ln -s ../../doOmimPhenotype.pl ./doOmimPhenotype.pl
 
   ../../buildOmimTracks.sh $db
   ../../flagOmimGene.py $db > omimGene2.prev.flagged
   ../../validateOmim.sh $db
   cd ..
 
   # install new tables
   for table in `cat ../omim.tables`
   do 
     new=$table"New"
     old=$table"Old"
     hgsqlSwapTables $db $new $table $old -dropTable3
   done
+
+  # archive the data
+  if [ ! -d ${WORKDIR}/archive/${db} ]; then
+    mkdir -p ${WORKDIR}/archive/${db}
+  fi
+  cd ${WORKDIR}/archive/${db}
+  mkdir ${today}
+  cd ${today}
+  printf "This directory contains a backup of the OMIM track data tables built on %s\n" "${today}" > README
+  for i in `cat ${WORKDIR}/omim.tables`
+  do
+    hgsql --raw -Ne "show create table ${i}" ${db} > ${i}.sql
+    hgsql -Ne "select * from ${i}" ${db} | gzip >  ${i}.txt.gz
+  done
+  cd ${WORKDIR}/${today}
+
 done
 
 
 rm -f "${WORKDIR}"/prev.md5sum.txt
 cp -p "${WORKDIR}/${today}"/md5sum.txt "${WORKDIR}"/prev.md5sum.txt
 echo "Omim Installed `date`" 
 
 else
     echo "No update `date` "
     cd "${WORKDIR}"
     rm -rf "${today}"
 fi