Postgresql – Restore server instance using logical backup and wal files

master-slave-replicationpostgresqlreplicationwrite-ahead-logging

Is it possible to restore a database instance using logical backup and wal files?

A senior SQL Server DBA asked me to implement below scenario in PostgreSQL

took the logical backup using pg_dumpall of the master then do failover after some time.
Now restore database instance using the logical backup of primary + wal files of primary + wal files of secondary.

Best Answer

Yes it is possible the logical backup will be having data before failover say u took it on 3pm it will have complete data till 3pm

And suppose you fail-over the master say on 4 pm the wal-files will have records of changes done from 3pm to 4pm.

So just create a postgresql instance with help of pg_createcluster and inserted the dump file first.

then copy the wall files to /var/lib/postgresql/9.1/main/pg_xlog/ path which is default path for most postgresql installation. then finally restart the services service postgresql restart