Postgresql – How to simulate postgresql recovery mode

postgresqlpostgresql-8.3

I would like to simulate putting postgresql into "recovery mode".
Few times i have situation where postgresql puted himself into recovery mode. In logs i had:

Oct 18 06:37:35 xx postgres[5738]: [19-1] 2014-10-18 06:37:35.441 CEST|5738|xx|yy|FATAL: the database system is in recovery mode

It was caused by oom which killed one of process.
But when i try to simulate it in test environment – postgresql restarts.

How to prevent postgresql from restart and let him stay in recovery mode?

Best Answer

If you want to force PostgreSQL into recovery, you can create a recovery.conf with no restore_command or streaming replication configuration set. Leave hot_standby set to off in postgresql.conf.

Personally I recommend taking a base backup (pg_basebackup -X stream) and using that, rather than doing it to the original DB.