Restore a PostgreSQL database

You can restore a PostgreSQL database with the native pg_restore command.

  1. Locate the dump file you created when backing up the PostgreSQL database.
  2. Shut down CollabNet TeamForge.
  3. Create a database and user with the names used for CollabNet TeamForge.
  4. Restore the database.
    createuser -U $CTFUSER createdb -E UTF8 -U $CTFUSER ctfdb pg_restore -d ctfdb
                ctfdb.tar
    Note: This example assumes that the name of the CollabNet TeamForge database is ctfdb.
    Tip: It may also be necessary to restore ownership of the restored tables to the ctfuser database user. Something like the following will work (again, assuming the database is called ctfdb):
    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.