Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[2e23dc]: dist / bin / dump-mysql.sh Maximize Restore History

Download this file

dump-mysql.sh    147 lines (126 with data), 4.0 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/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}"
echo "database wordnet${dbtag}"
dbms=mysql
dbuser=root
#dbcompatible='--compatible=mysql323'
dboptions='--extended-insert=FALSE'
if [ -z "$MYSQLPASSWORD" ]; then
MYSQLPASSWORD=$1
shift
if [ -z "$MYSQLPASSWORD" ]; then
read -s -p "enter ${dbuser}'s password: " MYSQLPASSWORD
echo
export MYSQLPASSWORD
fi
fi
# D I R S
thisdir=`dirname $(readlink -m $0)`
distdir="$(readlink -m ${thisdir}/..)"
#echo "distdir=${distdir}"
outdir=${distdir}/data/${dbms}/${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=""
lcomputedsensemaps=""
case ${dbtag} in
30)
lsenses="${lsenses}"
lcomputedsensemaps=""
lsynsetmaps="synsetmaps2030 synsetmaps2130"
;;
31)
lsenses="${lsenses} senses30"
lcomputedsensemaps="sensemaps3031"
lsynsetmaps="synsetmaps2031 synsetmaps2131 synsetmaps3031"
;;
31_snapshot*)
lsenses="${lsenses} senses30 senses31"
lcomputedsensemaps="sensemaps3031 sensemaps3131_snapshot"
lsynsetmaps="synsetmaps2031_snapshot synsetmaps2131_snapshot synsetmaps3031_snapshot synsetmaps3131_snapshot"
;;
*)
echo "illegal dbtag ${dbtag}"
exit 1
esac
legacy="${lsenses} ${lsensemaps} ${lsynsetmaps} ${lcomputedsensemaps}"
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 ${dbcompatible} ${dboptions} --no-create-db --no-create-info --add-drop-table --quote-names --databases ${db} --tables ${mytables} > ${outdir}/${dbms}-${mydomain}-data.sql
}
function schema()
{
mytables=$1
mydomain=$2
echo "* dumping schema of ${mytables}"
mysqldump -u ${dbuser} --password=$MYSQLPASSWORD --no-data ${dbcompatible} --add-drop-table --databases ${db} --tables ${mytables} --no-create-db | ./filter-schema-${dbms}.py > ${outdir}/${dbms}-${mydomain}-schema.sql
}
function constraints()
{
mydomain=$1
myswitch=${mydomain}
echo "* dumping constraints ${mydomain}"
${builderdir}/bin/run-${dbms}-${dbtag}.sh dump ${mydomain} constraint drops > ${outdir}/${dbms}-${mydomain}-unconstrain.sql 2> /dev/null
${builderdir}/bin/run-${dbms}-${dbtag}.sh dump ${mydomain} constraint creates > ${outdir}/${dbms}-${mydomain}-constrain.sql 2> /dev/null
}
function views()
{
mydomain=$1
myswitch=${mydomain}
echo "* dumping views ${mydomain}"
${builderdir}/bin/run-${dbms}-${dbtag}.sh dump ${mydomain} view creates > ${outdir}/${dbms}-${mydomain}-views.sql 2> /dev/null
}
# M A I N
rm -fR ${outdir}
mkdir -p ${outdir}
for domain in ${domains}; do
eval tables=\$${domain}
#echo "${domain} -> ${tables}"
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 log stats"
./stats-${dbms}.sh ${dbtag} $MYSQLPASSWORD
cd ${distdir}