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/decipher/checkDecipher.sh src/hg/utils/otto/decipher/checkDecipher.sh
index 2f20a31..f2a37b9 100755
--- src/hg/utils/otto/decipher/checkDecipher.sh
+++ src/hg/utils/otto/decipher/checkDecipher.sh
@@ -34,40 +34,54 @@
 
 perl login.perl > /dev/null 2>&1
 
 if test decipher-variants*.gpg -nt lastUpdate
 then
     today=`date +%F`
     mkdir -p $today
 
     CNV=decipher-cnvs*.gpg
     SNV=decipher-snvs*.gpg
     cp -p $CNV $SNV $today
 
     cd $today
 
     # unpack the gpg encrypted file
-    gpg --batch --passphrase-file "../gpg.pwd" ${CNV}
-    gpg --batch --passphrase-file "../gpg.pwd" ${SNV}
+    gpg --batch --passphrase-file "../gpg.pwd.new" ${CNV}
+    gpg --batch --passphrase-file "../gpg.pwd.new" ${SNV}
 
     # build the new DECIPHER track tables
     ../buildDecipher `basename $CNV .gpg` `basename $SNV .gpg`
     ../validateDecipher.sh hg19
 
     # now install
     for i in `cat ../decipher.tables`
     do 
 	n=$i"New"
 	o=$i"Old"
 	hgsqlSwapTables hg19 $n $i $o -dropTable3
     done
 
+    # now archive
+    if [ ! -d ${WORKDIR}/archive ]; then
+        mkdir -p ${WORKDIR}/archive
+    fi
+    cd ${WORKDIR}/archive
+    mkdir -p hg19/${today}
+    cd hg19/${today}
+    printf "This directory contains a backup of the Decipher track data tables built on %s\n" "${today}" > README 
+    for i in `cat ${WORKDIR}/decipher.tables`
+    do
+        hgsql --raw -Ne "show create table ${i}" hg19 > ${i}.sql
+        hgsql -Ne "select * from ${i}" hg19 | gzip >  ${i}.txt.gz
+    done
+
     echo "DECIPHER Installed `date`" 
 
     # Variants BED will be updated for both CNV and SNV updates
-    cd ..
-    cp -p decipher-var*.gpg ../lastUpdate
+    cd ${WORKDIR}
+    cp -p decipher-var*.gpg lastUpdate
 else
     echo "No update"
 fi
 
 rm decipher-*