PostgreSQL Continuous Archive
Enable archive mode
wal_level to at least
archive, please refer to Official Document for details.
archive_mode to at least
on, please refer to Official Document for details.
Create archive folder
Now let us create the archive folder for postgres user in operating system.
Launch database server
After launching database server, you could notice there is a new process very self-explanatory
postgres: archiver process
Add some data
For xlog purpose, we need to add some data like creating a new table, or DML.
Force xlog switch
Now this function take effect.
archive_status folder inside
$PGDATA we could found the updated status of archiving.
> ls $PGDATA/archive_status 00000001000000000000004A.done
$ARCHIVE_PATH side of view, we could see that specific xlog has been archived to our archive folder.
> ls $ARCHIVE_PATH 00000001000000000000004A
Because WAL is significantly useful for recovery, it is better to back them up by archive. But sometimes it is still not enough, we could use
rsync to send those WAL to some other place so that they will be preserved for longer term. I am not going to the details of it.
This tutorial is to tell you how to setup archive functionality for PostgreSQL with minimum configuration.
Backuping or Archiving xlog is to enable High Availability for our system.
With continuous archiving, we enabled Point-in-Time Recovery (PITR), my tutorial is at PITR.