/other/

Quickly copy a PostgreSQL database

2015-07-24 22:50:41

sudo -u postgres pg_dump -Fc shop > shop_copy.dump
sudo -u postgres psql

postgres=# create database shop2;
postgres=# \q

sudo -u postgres pg_restore -d shop2 shop_copy.dump
sudo -u postgres psql

postgres=# \l
COPY - SERVER DB
sudo -u postgres pg_dump -Fc btbw > btbw_copy_2016_07_23.dump

RESET - LOCAL DB
sudo -u postgres dropdb btbw
sudo -u postgres createdb btbw
sudo -u postgres pg_restore -d btbw btbw_copy_2016_07_23.dump