Move PostgreSQL database

December 5th, 2009 by raspi Leave a reply »

Moving PostgreSQL database to different name is pretty hard compared to MySQL. But here’s how you do it:

$ pg_dump --no-acl --no-owner -U <username> -h <host> -Fc <database> > <dump filename>
$ pg_restore -1 -c -U <username> -d <database> -h <host> --no-owner <dump filename>
$ pg_dump --no-acl --no-owner -U old -h 127.0.0.1 -Fc olddb > old.dump
$ pg_restore -1 -c -U newuser -d newdb -h postgresql.lan --no-owner old.dump
Advertisement

Leave a Reply