source: asadb/util/warehouse-refresh.sh

space-accessstablestage
Last change on this file was 2ca19cb, checked in by MIT Association of Student Activities <asa@…>, 14 years ago

Allow running warehouse-refresh.sh from anywhere

  • Property mode set to 100755
File size: 992 bytes
RevLine 
[14e96b3]1#!/bin/bash -e
2
3author="$USER warehouse-refresh.sh on $(hostname) <asa-db@mit.edu>"
[774f999]4basedir="$(dirname "$(readlink -f "$0")")"
5database="$("$basedir/../settings/fetch" database NAME)"
[14e96b3]6
7date
8
[2ca19cb]9cd "$basedir/saved-data"
[14e96b3]10
[774f999]11mysqldump --skip-extended-insert "$database" > data.sql
[14e96b3]12
13echo
14echo Committing previous DB:
15git commit data.sql -m "Previous ASA database: $(date +%F)" --allow-empty --author="$author"
16
17echo
18echo Changes in this commit:
[5c77dea]19git show --stat
[14e96b3]20
21echo
22echo
23echo Performing replacement
[774f999]24echo "TRUNCATE TABLE groups_group" | mysql "$database"
[14e96b3]25../import_db.py < ../warehouse-dump.csv > /dev/null
[774f999]26mysqldump --skip-extended-insert "$database" > data.sql
[14e96b3]27
28echo
29echo Committing new DB:
30git commit data.sql -m "New ASA database: $(date +%F)" --allow-empty --author="$author"
31
32echo
33echo Changes in this commit:
[5c77dea]34git show --stat
[14e96b3]35
36echo
37echo
38echo Disk usage:
39du -h --max-depth=1
40
41echo
42echo "gc'ing..."
43time git gc
44echo "repack'ing..."
45time git repack
46
47echo
48echo Disk usage:
49du -h --max-depth=1
50
51date
Note: See TracBrowser for help on using the repository browser.