Incremental backup and restore
This tutorial will show you how to do an incremental backup and a restore using pgmoneta.
Preface
This tutorial assumes that you have an installation of PostgreSQL 17+ and pgmoneta.
See Install pgmoneta for more detail.
Full backup
pgmoneta-cli -c pgmoneta.conf backup primary
pgmoneta-cli -c pgmoneta.conf backup primary
will take a full backup of the [primary]
host.
(pgmoneta
user)
List backups
pgmoneta-cli -c pgmoneta.conf list-backup primary
pgmoneta-cli -c pgmoneta.conf list-backup primary
(pgmoneta
user)
Incremental backup
pgmoneta-cli -c pgmoneta.conf backup primary newest
pgmoneta-cli -c pgmoneta.conf backup primary newest
will take an incremental backup of the [primary]
host.
Note that currently branching is not allowed for incremental backup -- a backup can have at most 1 incremental backup child.
(pgmoneta
user)
List backups
pgmoneta-cli -c pgmoneta.conf list-backup primary
pgmoneta-cli -c pgmoneta.conf list-backup primary
(pgmoneta
user)
Restore
pgmoneta-cli -c pgmoneta.conf restore primary newest current /tmp/
pgmoneta-cli -c pgmoneta.conf restore primary newest current /tmp/
will take the latest backup and all Write-Ahead Log (WAL) segments and restore it into the /tmp/primary-<timestamp>
directory for an up-to-date copy.
The 2nd to last parameter allows
current
means copy the Write-Ahead Log (WAL ), and restore to first stable checkpointname=X
means copy the Write-Ahead Log (WAL ), and restore to the label specifiedxid=X
means copy the Write-Ahead Log (WAL ), and restore to the XID specifiedtime=X
means copy the Write-Ahead Log (WAL ), and restore to the timestamp specifiedlsn=X
means copy the Write-Ahead Log (WAL ), and restore to the Log Sequence Number (LSN) specifiedinclusive=X
means that the restore is inclusive of the specified informationtimeline=X
means that the restore is done to the specified information timelineaction=X
means which action should be executed after the restore (pause, shutdown)primary
means that the cluster is setup as a primaryreplica
means that the cluster is setup as a replica
(pgmoneta
user)