Archiving the transaction log
After taking a look at the big picture, we can see how things can be put to work.
The first thing you have to do when it comes to Point-in-time Recovery is archive the XLOG. PostgreSQL offers all the configuration options related to archiving through postgresql.conf
.
Let us see step by step what has to be done in postgresql.conf
to start archiving:
- First of all, you should turn
archive_mod
e on. - In the second step, you should configure your
archive_command
. Thearchive_command
is a simple shell, and it needs just two parameters to operate properly:%p
: This is a placeholder representing the XLOG file that should be archived, including its full path (source).%f
: This variable holds the name of XLOG without the path pointing to it.
Let's set up archiving now. To do so, we should create a place to put the XLOG. Ideally, the XLOG is not stored on the same hardware as the database instance you want to archive. For the sake of this example, we assume that we want to...