Is it possible to restore a Postgres database by simply swapping out some files for speed?

前端 未结 2 2009
时光取名叫无心
时光取名叫无心 2021-01-25 22:11

This is a general Postgres backup and restore method question, based on the following use case for a non production server (i.e. a local testing server).

I have a ~20gb

2条回答
  •  悲&欢浪女
    2021-01-25 22:52

    Your fastest solution is probably to just do this via the file system.

    Stop the server and make a local copy of your entire database cluster, i.e. everything under $PGDATA, inclusive. Start the server and do your mangling. When you need to refresh your database, stop the server and copy the files back in from your backup location. Note that this affects the entire cluster, so you cannot do this if other databases in the same cluster are in production use: everything is frozen in the state it was in when you first made the backup.

    The alternative is to use pg_dump in binary mode, but probably quite a bit slower than the manual method. It is the only solution if other databases in the cluster need to be preserved.

提交回复
热议问题