Re: Proper way to restore from a basebackup without the WAL-files?

From: Gustav Karlsson <gustav(dot)karlsson(at)bekk(dot)no>
To: Keith <keith(at)keithf4(dot)com>
Cc: Kevin Grittner <kgrittn(at)gmail(dot)com>, John Scalia <jayknowsunix(at)gmail(dot)com>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Proper way to restore from a basebackup without the WAL-files?
Date: 2015-12-16 07:30:06
Message-ID: 13317938-3296-4FB9-9236-174D7A0EEC16@bekk.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Thanks everyone for your answers and pointing me to relevant documentation! I will attempt to do a dump and restore immediately after pg_resetxlog and see where that leaves me.

It is indeed a one off for us. Generally we have a complete WAL-history.

Regards,
Gustav

On Dec 15, 2015, at 7:58 PM, Keith <keith(at)keithf4(dot)com<mailto:keith(at)keithf4(dot)com>> wrote:

On Tue, Dec 15, 2015 at 1:19 PM, Kevin Grittner <kgrittn(at)gmail(dot)com<mailto:kgrittn(at)gmail(dot)com>> wrote:
On Tue, Dec 15, 2015 at 11:47 AM, John Scalia <jayknowsunix(at)gmail(dot)com<mailto:jayknowsunix(at)gmail(dot)com>> wrote:

> If you absolutely must use the pg_basebackup as your source and I'm assuming
> you have a tarball without any of WAL files, you could expand the tarball
> into you data directory, and use pg_resetxlog to "fool" the master into
> starting up. I only say "fool" as it just builds you a blank WAL file which
> this system can use as its integrity check and properly start.

Please note that this will generally leave you with a corrupted
cluster; you would be well advised to follow the advice in the
documentation:

http://www.postgresql.org/docs/9.4/interactive/app-pgresetxlog.html

| After running this command, it should be possible to start the
| server, but bear in mind that the database might contain
| inconsistent data due to partially-committed transactions. You
| should immediately dump your data, run initdb, and reload. After
| reload, check for inconsistencies and repair as needed.

--
Kevin Grittner
EDB: http://www.enterprisedb.com<http://www.enterprisedb.com/>
The Enterprise PostgreSQL Company

--
Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org<mailto:pgsql-admin(at)postgresql(dot)org>)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Hopefully this is just a one-off occurrence where you needed to do this. The best thing long term would be to ensure you're backing up the WAL files along with pg_basebackup. Use the -X option with pg_basebackup so you have a consistent backup that can be started on its own. Or make sure you're backing up your WAL files another way (archive_command on master, pg_receivexlogs, etc).

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Guillaume Lelarge 2015-12-16 09:47:55 Re: [REASSIGN confusion]
Previous Message Michał Nowak 2015-12-15 19:34:28 semop hanging - Postgres 9.4.4