Restore
Restore a backup
We can restore a backup from the primary with the following command
pgmoneta-cli restore primary newest current /tmpwhere
currentmeans copy the Write-Ahead Log (WAL ), and restore to first stable checkpointname=Xmeans copy the Write-Ahead Log (WAL ), and restore to the label specifiedxid=Xmeans copy the Write-Ahead Log (WAL ), and restore to the XID specifiedtime=Xmeans copy the Write-Ahead Log (WAL ), and restore to the timestamp specifiedlsn=Xmeans copy the Write-Ahead Log (WAL ), and restore to the Log Sequence Number (LSN) specifiedinclusive=Xmeans that the restore is inclusive of the specified informationtimeline=Xmeans that the restore is done to the specified information timelineaction=Xmeans which action should be executed after the restore (pause, shutdown)primarymeans that the cluster is setup as a primaryreplicameans that the cluster is setup as a replica
And, you will get output like
Header:
ClientVersion: 0.20.0
Command: 3
Output: 0
Timestamp: 20240928130406
Outcome:
Status: true
Time: 00:00:00
Request:
Backup: newest
Directory: /tmp
Position: current
Server: primary
Response:
Backup: 20240928065644
BackupSize: 8531968
Comments: ''
Compression: 2
Encryption: 0
MajorVersion: 17
MinorVersion: 0
RestoreSize: 48799744
Server: primary
ServerVersion: 0.20.0This command take the latest backup and all Write-Ahead Log (WAL) segments and restore it into the /tmp/primary-20240928065644 directory for an up-to-date copy.
Hot standby
In order to use hot standby, simply add
hot_standby = /your/local/hot/standby/directoryto the corresponding server section of pgmoneta.conf. [pgmoneta][pgmoneta] will create the directory if it doesn't exist, and keep the latest backup in the defined directory.
You can also configure muptiple hot standby directories (up to 8) by providing comma-separated paths:
/path/to/hot/standby1,/path/to/hot/standby2,/path/to/hot/standby3[pgmoneta][pgmoneta] will maintain identical copies of the hot standby in all specified directories.
You can use
hot_standby_overrides = /your/local/hot/standby/overrides/to override files in the hot_standby directories. The overrides will be applied to all hot_standby directories.
Tablespaces
By default tablespaces will be mapped to a similar path than the original one, for example /tmp/mytblspc becomes /tmp/mytblspchs.
However, you can use the directory name to map it to another directory, like
hot_standby_tablespaces = /tmp/mytblspc->/tmp/mybcktblspcYou can also use the OID for the key part, like
hot_standby_tablespaces = 16392->/tmp/mybcktblspcMultiple tablespaces can be specified using a , between them.