Postgresql 中文操作指南
Chapter 51. Archive Modules
Table of Contents
PostgreSQL 提供了为连续归档创建自定义模块的基础架构(参见 Section 26.3 )。尽管通过 shell 命令(即 archive_command )进行归档要简单得多,但是自定义归档模块通常会更健壮且性能更好。
PostgreSQL provides infrastructure to create custom modules for continuous archiving (see Section 26.3). While archiving via a shell command (i.e., archive_command) is much simpler, a custom archive module will often be considerably more robust and performant.
当配置自定义 archive_library 时,PostgreSQL 会将完成的 WAL 文件提交到模块,服务器会避免回收或删除这些 WAL 文件,直到该模块表示已成功归档这些文件。最终由模块决定如何处理每个 WAL 文件,但 Section 26.3.1 中列出了许多建议。
When a custom archive_library is configured, PostgreSQL will submit completed WAL files to the module, and the server will avoid recycling or removing these WAL files until the module indicates that the files were successfully archived. It is ultimately up to the module to decide what to do with each WAL file, but many recommendations are listed at Section 26.3.1.
归档模块至少包含初始化函数(参见 Section 51.1 )和必需的回调(参见 Section 51.2 )。但是,归档模块还可以执行更多内容(例如声明 GUC 和注册后台工作人员)。
Archiving modules must at least consist of an initialization function (see Section 51.1) and the required callbacks (see Section 51.2). However, archive modules are also permitted to do much more (e.g., declare GUCs and register background workers).
contrib/basic_archive 模块包含一个工作示例,演示了一些有用的技术。
The contrib/basic_archive module contains a working example, which demonstrates some useful techniques.