-
-
Save fwenzel/325266 to your computer and use it in GitHub Desktop.
Make a small AMO database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DATE=$(date +%Y-%m-%d) | |
DIR="$(pwd)/amo-slim-$DATE" | |
rm -rf $DIR | |
mkdir -p $DIR | |
cd $DIR | |
DB='remora' | |
DUMP='mysqldump --single-transaction' | |
SCHEMA='schema.sql' | |
USERS='users.sql' | |
FINAL="amo-slim-$DATE.sql.gz" | |
WHERE=$(cat <<EOF|python | |
tables = """ | |
addons_users | |
approvals | |
api_auth_tokens | |
editor_subscriptions | |
groups_users | |
reviews | |
reviews_moderation_flags | |
versioncomments | |
users_versioncomments | |
collection_subscriptions | |
collections_users | |
collections_votes | |
howto_votes | |
users_tags_addons | |
hubrsskeys | |
""".split() | |
print ' UNION DISTINCT '.join('SELECT user_id FROM %s' % t for t in tables) | |
EOF) | |
echo 'dumping the schema...' | |
$DUMP --no-data $DB > $SCHEMA | |
echo 'dumping the good users...' | |
$DUMP $DB users --where="id IN ($WHERE)" > $USERS | |
echo 'dumping most tables...' | |
$DUMP --ignore-table=$DB.download_counts \ | |
--ignore-table=$DB.update_counts \ | |
--ignore-table=$DB.logs_parsed \ | |
--ignore-table=$DB.cake_sessions \ | |
--ignore-table=$DB.stats_addons_collections_counts \ | |
--ignore-table=$DB.users \ | |
--ignore-table=$DB.facebook_data \ | |
--ignore-table=$DB.facebook_detected \ | |
--ignore-table=$DB.facebook_favorites \ | |
--ignore-table=$DB.facebook_sessions \ | |
--ignore-table=$DB.facebook_users \ | |
--ignore-table=$DB.cache $DB | cat $SCHEMA $USERS - | gzip > $FINAL | |
mv $FINAL .. | |
rm -rf $DIR | |
echo "The goods are in $FINAL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment