25 April 2011

PostgreSQL Backup and Restore

To backup and restore PostgreSQL with ignoring of database version us pg_dump and pg_restore like in next commands:

For Backup :

C:\pgsql\bin\pg_dump.exe
--host localhost
--port 5432
--username "username"
--format custom
--blobs
--ignore-version
--verbose
--file "postgresql.backup" databasename

For Restore :

C:\pgsql\bin\pg_restore.exe
--host localhost
--port 5432
--username username
--dbname databasename
--clean
--ignore-version
--verbose "postgresql.backup"

20 April 2011

How to change encoding type

Dump your database, drop your database, recreate your database with the 
different encoding, reload your data.  Make sure the client encoding is 
set correctly during all this.
 
P.S.: 
CREATE DATABASE test
  WITH OWNER = postgres
       ENCODING = 'WIN1250'
       TABLESPACE = pg_default
       LC_COLLATE = 'Serbian (Latin)_Serbia.1250'
       LC_CTYPE = 'Serbian (Latin)_Serbia.1250'
       CONNECTION LIMIT = -1;