Moving PostgreSQL (on Ubuntu Linux)

NOTE: This is a user submitted instruction for reference. Your environment may be different.


On the original server, backup the kwok database,

pg_dump dbname | gzip > filename.gz

For example:

pg_dump –U postgres –W kwokdb | gzip > kwokdb.gz

Now copy this file to new server (use SFTP or something)

On the new server (ubuntu in this case, so everything is sudo'ed), create a new database and upload the data.

createdb dbname
gunzip -c filename.gz | psql dbname

For example:

sudo createdb -U postgres -W kwokdb
gunzip -c kwokdb.gz | sudo psql -U postgres -W kwokdb

Note that -W prompts for the password.