You can restore a PostgreSQL database with the native pg_restore command.
createuser -U $CTFUSER createdb -E UTF8 -U $CTFUSER ctfdb pg_restore -d ctfdb
ctfdb.tar
for i in `echo "\d" | psql ctfdb | awk {'print $3'}` do echo "ALTER TABLE $i OWNER TO $SFUSER;" | psql ctfdb done
See the PostgreSQL pg_restore man page for more examples and information.