Unzip compressed dump and import via psql

Use compressed pg_dump:

  1. Using -Z
    pg_dump dbname -Fp -Z6 -v > filename.gz
  2. Using gzip
    pg_dump dbname | gzip > filename.gz
    Reload data:
  3. gunzip
    gunzip -c filename.gz | psql -Upostgres -ddbname
  4. cat
    cat filename.gz |gunzip|psql -Upostgres -ddbname
    Examples:
    1.pg_dump -d test -t t_auth* -Fp -Z6 -v > /home/data/auth.gz
    2.gunzip -c /home/data/auth.gz |psql -Upostgres -d auth
    3.cat /home/data/auth.gz |gunzip |psql -Upostgres -d auth

refer:
[1] postgresql-13-A4.pdf 25.1.3. Handling Large Databases

posted @ 2025-04-21 17:17  program_keep  阅读(5)  评论(0)    收藏  举报