开发者

How can I backup everything in Postgres 8, including indexes?

开发者 https://www.devze.com 2023-03-23 00:29 出处:网络
When I make a backup in postgres 8 it only backs up the schemas and data, b开发者_如何学Pythonut not the indexes. How can i do this?Sounds like you\'re making a backup using the pg_dump utility.That s

When I make a backup in postgres 8 it only backs up the schemas and data, b开发者_如何学Pythonut not the indexes. How can i do this?


Sounds like you're making a backup using the pg_dump utility. That saves the information needed to recreate the database from scratch. You don't need to dump the information in the indexes for that to work. You have the schema, and the schema includes the index definitions. If you load this backup, the indexes will be rebuilt from the data, the same way they were created in the first place: built as new rows are added.

If you want to do a physical backup of the database blocks on disk, which will include the indexes, you need to do a PITR backup instead. That's a much more complicated procedure, but the resulting backup will be instantly usable. The pg_dump style backups can take quite some time to restore.


If I understand you correctly, you want a dump of the indexes as well as the original table data.

pg_dump will output CREATE INDEX statements at the end of the dump, which will recreate the indexes in the new database.

You can do a PITR backup as suggested by Greg Smith, or stop the database and just copy the binaries.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号