Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Import and Export PostgreSQL DB in Gzip Way

Permalink

Export PostgreSQL DB in gzip format

pg_dump open_project_prod -O -x | gzip > open_project_prod_db.sql.gz

Import directly in gzip format

psql -d postgres
DROP DATABASE openproject_development;
CREATE DATABASE openproject_development WITH ENCODING='UTF8';
ALTER DATABASE openproject_development SET TIMEZONE='Asia/Shanghai';
\q
# gunzip < open_project_prod_db.sql.gz | psql -d open_project_ppp --username=op_ppp -W --host=172.17.1.66
gunzip < open_project_prod_db.sql.gz | psql -d openproject_development

Comments