[19e22f]: dist / bin / dump-mysql.sh Maximize Restore History

Download this file

dump-mysql.sh    132 lines (117 with data), 3.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# bbou@ac-toulouse.fr
# 25/11/2013
# [--schema] 30|31|31_snapshot [password]
schema=
if [ "$1" == "--schema" ]; then
schema=true
shift
fi
dbtag=$1
shift
if [ -z "${dbtag}" ]; then
echo "$0 <dbtag:30|31|31_snapshot>"
exit 1
fi
# D A T A B A S E
db="wordnet${dbtag}"
dbtype=mysql
dbuser=root
#compatible=--compatible=mysql323
echo "database wordnet${dbtag}"
if [ -z "$MYSQLPASSWORD" -a -z "$1" ]; then
read -s -p "enter ${dbuser}'s password: " MYSQLPASSWORD
echo
export MYSQLPASSWORD
else
MYSQLPASSWORD=$1
shift
fi
# D I R S
distdir="`dirname $(readlink -m $0)`/"
distdir="$(readlink -m ${distdir}/..)"
#echo "distdir=${distdir}"
outdir=${distdir}/data/${dbtype}/${dbtag}
outdir="$(readlink -m ${outdir})"
#echo "outdir=${outdir}"
builderdir=${distdir}/../run
builderdir="$(readlink -m ${builderdir})"
#echo "builderdir=${builderdir}"
# T A B L E S
wn="words casedwords senses synsets linktypes semlinks lexlinks postypes lexdomains morphmaps morphs samples vframemaps vframes vframesentencemaps vframesentences adjpositions adjpositiontypes"
lsenses="senses20 senses21"
lsensemaps="sensemaps2021 sensemaps2130"
lsynsetmaps="synsetmaps2030 synsetmaps2130"
lcomputedsynsetmaps=""
case ${dbtag} in
31)
lsenses="${lsenses} senses30"
lsynsetmaps="${lsynsetmaps} synsetmaps3031"
;;
31_snapshot*)
lsenses="${lsenses} senses30 senses31"
lsynsetmaps="${lsynsetmaps} synsetmaps3031"
lcomputedsynsetmaps="${lcomputedsynsetmaps} sensemaps3031"
;;
esac
legacy="${lsenses} ${lsensemaps} ${lsynsetmaps} ${lcomputedsynsetmaps}"
vn="vnclasses vnclassmembers vnclassmembersenses vngroupings vngroupingmaps vnrolemaps vnroles vnroletypes vnselrestrs vnselrestrtypes vnframemaps vnframes vnframenames vnframesubnames vnsemantics vnsyntaxes vnpredicatemaps vnpredicates vnexamplemaps vnexamples"
bnc="bncs bncimaginfs bncconvtasks bncspwrs"
sumo="sumofiles sumoformulas sumoterms sumotermattrs sumomaps sumoparsemaps"
xwn="xwnparselfts xwnwsds"
glf="glfs"
ilfwn="ilfs"
logs="logs"
# D O M A I N S
extensions="legacy vn bnc sumo xwn glf ilfwn logs"
domains="wn ${extensions}"
# F U N C T I O N S
function data()
{
mytables=$1
mydomain=$2
echo "* dumping data of ${mytables}"
mysqldump -u ${dbuser} --password=$MYSQLPASSWORD ${compatible} --no-create-db --no-create-info --add-drop-table --quote-names --databases ${db} --tables ${mytables} > ${outdir}/${dbtype}-${mydomain}-data.sql
}
function schema()
{
mytables=$1
mydomain=$2
echo "* dumping schema of ${mytables}"
mysqldump -u ${dbuser} --password=$MYSQLPASSWORD --no-data ${compatible} --add-drop-table --databases ${db} --tables ${mytables} --no-create-db | ./filter-schema-${dbtype}.py > ${outdir}/${dbtype}-${mydomain}-schema.sql
}
function constraints()
{
mydomain=$1
myswitch=${mydomain}
echo "* dumping views ${mydomain}"
${builderdir}/bin/run-${dbtype}-${dbtag}.sh dump ${mydomain} constraint creates > ${outdir}/${dbtype}-${mydomain}-constrain.sql 2> /dev/null
${builderdir}/bin/run-${dbtype}-${dbtag}.sh dump ${mydomain} constraint drops > ${outdir}/${dbtype}-${mydomain}-unconstrain.sql 2> /dev/null
}
function views()
{
mydomain=$1
myswitch=${mydomain}
echo "* dumping constraints ${mydomain}"
${builderdir}/bin/run-${dbtype}-${dbtag}.sh dump ${mydomain} view creates > ${outdir}/${dbtype}-${mydomain}-views.sql 2> /dev/null
}
# M A I N
if [ ! -z "$@" ]; then
export domains="$@"
fi
rm -fR ${outdir}
mkdir -p ${outdir}
for domain in ${domains}; do
eval tables=\$${domain}
data "${tables}" "${domain}"
if [ ! -z "$schema" ]; then
schema "${tables}" "${domain}"
constraints "${domain}"
views "${domain}"
fi
done
# S T A T S
cd ${builderdir}/bin
echo "* making logs"
./stats-${dbtype}.sh ${dbtag} $MYSQLPASSWORD
cd ${distdir}