Here’s what I do on my development box, though making a backup of a fresh database and restoring from the web interface is a little faster, I think.
#!/usr/bin/env bash
if [ ! -f discourse.sublime-project ]
then
echo "Dude. There's no Discourse here."
exit
else
echo Killing any running rubies. . .
killall ruby
RAILS_ENV=development
export RAILS_ENV
sleep 5 # make sure they all quit
RAILS_ENV=development bundle exec rake db:drop db:create db:migrate
cat <<EOF | bundle exec rake admin:create
pfaffman@gmail.com
1secretpassword!
1secretpassword!
EOF
echo Flushing Redis
redis-cli flushall
echo Done.
fi