You can restore a PostgreSQL database with the native pg_restore or
psql commands, or by using the db.py script.
Note: You can use the db.py script to restore PostgreSQL data in all setups except the dedicated
database server setup where the TeamForge database
is not installed. In a dedicated database setup, you can restore the PostgreSQL database using the
pg_restore or psql command.
Using db.py:
-
To restore the entire PostgreSQL database, run this command.
- ./db.py -a restore -f /tmp/backup/
-
To restore only the ctf database, run this command.
- ./db.py -a restore -t ctf -f /tmp/backup/
-
To restore only the datamart, run this command.
- ./db.py -a restore -t reporting -f /tmp/backup/
Using pg_restore or psql:
-
In a dedicated database setup, you can use pg_restore or
psql:
-
Locate the dump file you created when backing up the PostgreSQL database.
-
Shut down CollabNet
TeamForge .
-
Create a database and user with the names used for CollabNet
TeamForge .
createuser -U $CTFUSER createdb -E UNICODE -U $CTFUSER ctfdb
-
Restore the database using either the pg_restore or
psql utility. Run one of these commands:
- pg_restore -d ctfdb ctfdb.tar
- pg_restore -d <dbname> ctfdb.dmp
- psql ctfdb <
/tmp/backup_dir/teamforge_data_backup.dmp
Note: This example assumes that the name of the
TeamForge database is
ctfdb.
Tip: It may also be necessary to restore ownership of the restored tables
to the
ctfuser database user. 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