Monday, January 30, 2012

getting slash code

this will work

git clone --branch live  git://slashcode.git.sourceforge.net/gitroot/slashcode/slashcode

Sunday, January 8, 2012

diff between two mysql databases

get differences between two iterations of the same database; requires the username and the password be set in ~/.my.cnf ; do not add the database name to ~/.my.cnf

... not perl, posting here so I'll have access to the script when not at home


#!/usr/bin/env bash

echo "" > differences.diff;

DB_ORIGINAL="db_old"
DB_MODIFIED="db_modified"

declare -A SKIP_TABLES
SKIP_TABLES[hits]=1
SKIP_TABLES[spam_reports]=1
SKIP_TABLES[searches]=1

for i in `mysql $DB_ORIGINAL --skip-column-names -e "show tables" | awk '{print $1}'`;
do
echo "looking at " $i;
echo "TABLE " $i >> differences.diff

mysqldump --no-data $DB_MODIFIED $i > $i.definition.modified.sql;
mysqldump --no-data $DB_ORIGINAL $i > $i.definition.original.sql;
diff $i.definition.original.sql $i.definition.modified.sql >> differences.diff;

#clean up
rm $i.definition.original.sql
rm $i.definition.modified.sql
# skip data
if [[ ${SKIP_TABLES[$i]} = 1 ]]
then
echo "skipping data for " $i;
continue;
fi

mysqldump --skip-extended-insert --no-create-info $DB_MODIFIED $i > $i.data.modified.sql;
mysqldump --skip-extended-insert --no-create-info $DB_ORIGINAL $i > $i.data.original.sql;

diff $i.data.original.sql $i.data.modified.sql | grep -v ' Host:' >> differences.diff;

# clean up
rm $i.data.original.sql;
rm $i.data.modified.sql;
done