-
Notifications
You must be signed in to change notification settings - Fork 7
/
mysql-dump.sh
executable file
·26 lines (24 loc) · 2.09 KB
/
mysql-dump.sh
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
#!/bin/bash
destination='./model/5. sindict.sql'
gloss_group_id=30
echo "Exporting languages..."
mysqldump -h $1 -u $2 --single-transaction -p $3 languages > "$destination" # deliberately recreate (assuming this is running post migration)
echo "Exporting accounts..."
mysqldump -h $1 -u $2 --no-create-info --single-transaction -p $3 accounts --where 'id = 1' >> "$destination" # DO NOT CHANGE! This is an account placeholder for SinDict
echo "Exporting speech..."
mysqldump -h $1 -u $2 --no-create-info --single-transaction -p $3 speeches --where "id in(select distinct speech_id from glosses where gloss_group_id in($gloss_group_id))" >> "$destination"
echo "Exporting words..."
mysqldump -h $1 -u $2 --no-create-info --single-transaction -p $3 words --where "id in(select distinct word_id from glosses where gloss_group_id in($gloss_group_id))" >> "$destination"
echo "Exporting senses..."
mysqldump -h $1 -u $2 --no-create-info --single-transaction -p $3 senses --where "id in(select distinct sense_id from glosses where gloss_group_id in($gloss_group_id))" >> "$destination"
echo "Exporting gloss groups..."
mysqldump -h $1 -u $2 --no-create-info --single-transaction -p $3 gloss_groups --where "id in($gloss_group_id)" >> "$destination"
echo "Exporting glosses..."
mysqldump -h $1 -u $2 --no-create-info --single-transaction -p $3 glosses --where "gloss_group_id in($gloss_group_id)" >> "$destination"
echo "Exporting gloss translations..."
mysqldump -h $1 -u $2 --no-create-info --single-transaction -p $3 translations --where "gloss_id in(select distinct id from glosses where gloss_group_id in($gloss_group_id))" >> "$destination"
echo "Exporting gloss keywords..."
mysqldump -h $1 -u $2 --no-create-info --single-transaction -p $3 keywords --where "gloss_id in(select distinct id from glosses where gloss_group_id in($gloss_group_id))" >> "$destination"
echo "Exporting search keywords..."
mysqldump -h $1 -u $2 --no-create-info --single-transaction -p $3 search_keywords --where "entity_name = 'gloss' and entity_id in(select distinct id from glosses where gloss_group_id in($gloss_group_id))" >> "$destination"
echo "Done!"