PostgreSQL: improving pg_dump, pg_restore performance

后端 未结 6 2214
眼角桃花
眼角桃花 2020-12-22 16:15

When I began, I used pg_dump with the default plain format. I was unenlightened.

Research revealed to me time and file size improvements with pg_

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-22 16:40

    I assume you need backup, not a major upgrade of database.

    For backup of large databases you should setup continuous archiving instead of pg_dump.

    1. Set up WAL archiving.

    2. Make your base backups for example every day by using
      psql template1 -c "select pg_start_backup('`date +%F-%T``')" rsync -a --delete /var/lib/pgsql/data/ /var/backups/pgsql/base/ psql template1 -c "select pg_stop_backup()"`

    A restore would be as simple as restoring database and WAL logs not older than pg_start_backup time from backup location and starting Postgres. And it will be much faster.

提交回复
热议问题