Re: standby, pg_basebackup and last xlog file

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Миша Тюрин <tmihail(at)bk(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: standby, pg_basebackup and last xlog file
Date: 2013-01-21 08:08:48
Message-ID: 50FCF790.5070100@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 21.01.2013 09:14, Миша Тюрин wrote:
> Is there any reason why pg_basebackup has limitation in an online backup from the standby: "The backup history file is not created in the database cluster backed up." ?

WAL archiving isn't active in a standby, so even if it created a backup
history file, it wouldn't go anywhere. Also, the way the backup history
files are named, if you take a backup on the master at the same time (or
another backup at the same time in the standby), you would end up with
multiple backup history files with the same name.

> So i can't get last xlog file needed to restore :(

Good point. That was an oversight in the patch that allowed base backups
from a standby.

> Also maybe i can use something like ( pg_last_xlog_replay_location() + 1 ) after pg_basebackup finished.

Yeah, that should work.

> Does anybody know true way to getting last xlog file in case of applying pg_basebackup to standby?
> How pg_basebackup gets last xlog file in case of standby and -x option?

The server returns the begin and end WAL locations to pg_basebackup,
pg_basebackup just doesn't normally print them out to the user. In
verbose mode, it does actually print them out, but only with -x, so that
doesn't help you either. If you can compile from source, you could
modify pg_basebackup.c to print the locations without -x and --verbose,
search lines that print out "transaction log start point / end position".

As a workaround, without modifying the source, you can do this after
pg_basebackup has finished, to get the first WAL file you need:

$ pg_controldata backupdir | grep "REDO WAL file"
Latest checkpoint's REDO WAL file: 000000030000000000000009

And as you suggested, pg_last_xlog_replay_location() for the last WAL
file you need.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Xi Wang 2013-01-21 08:35:29 Re: [PATCH] Fix NULL checking in check_TSCurrentConfig()
Previous Message Andrew Dunstan 2013-01-21 08:01:55 Re: Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]