Re: Replaying xlogs from beginning

From: otheus uibk <otheus(dot)uibk(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Replaying xlogs from beginning
Date: 2016-02-17 16:16:16
Message-ID: CALbQNd1ckhCBUaoyDTd=4tUJZtL90JgqRfONjNCZmCmO5e9pFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I came up with an answer to the _second_ question (how do I do this from a
new instance?).

In the new instance directory:
1. Hack the system ID in the global/pg_control file to that of the original
instance.
1a. Use pg_controlinfo to get the hex version of the control id:
$ pg_controldata | perl -l -n -e 'if (/^Database system
identifier:\s+(\d+)$/) { $sysid=sprintf("%x",$1);print join(" ",reverse
$sysid=~m/../g); exit; }'
fb fb 59 56 b9 31 58 53
1b. Use a hex editor (vim with xxd / xxd -r will do) to replace the
first bytes with these values.

2. The new control file will be unusable because its CRC won't match. Fix
that with pg_resetlog.
$ pg_resetlog -f

3. Copy the very first pg_xlog file into place. The rest can be copied by
hand or found using whatever you use for the "restore_command"

4. Create recovery.conf file.

Start instance.

Again, this worked for me. What I want to be sure of is: does this really
work? And I still want to know: can I do this without creating a new
instance?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2016-02-17 16:23:39 Re: Replaying xlogs from beginning
Previous Message Alex Magnum 2016-02-17 16:05:07 Log Monitoring with PG Admin