Skip to content

OCIO y TECnología

  • Privacy Policy
Offcanvas

  • Register
  • Lost your password ?

OCIO y TECnología

  • Home » 
  • Tecnología » 
  • Data bases » 
  • Recover corrupted Postgres DB WAL

Recover corrupted Postgres DB WAL

Emilio González Montaña 2024/04/22 0

How to recover from PANIC: could not locate a valid checkpoint record.

Status: Downloaded newer image for postgres:13.5

PostgreSQL Database directory appears to contain a database; Skipping initialization

2024-04-16 18:34:27.383 UTC [1] LOG: starting PostgreSQL 13.5 (Debian 13.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2024-04-16 18:34:27.384 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2024-04-16 18:34:27.384 UTC [1] LOG: listening on IPv6 address "::", port 5432
2024-04-16 18:34:27.389 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-04-16 18:34:27.410 UTC [26] LOG: database system was shut down at 2024-04-16 11:38:03 UTC
2024-04-16 18:34:27.532 UTC [26] LOG: invalid resource manager ID 72 at 2/72A46D68
2024-04-16 18:34:27.532 UTC [26] LOG: invalid primary checkpoint record
2024-04-16 18:34:27.532 UTC [26] PANIC: could not locate a valid checkpoint record
2024-04-16 18:34:27.641 UTC [1] LOG: startup process (PID 26) was terminated by signal 6: Aborted
2024-04-16 18:34:27.641 UTC [1] LOG: aborting startup due to startup process failure
2024-04-16 18:34:27.644 UTC [1] LOG: database system is shut down

Make a copy of the corrupted data

Stop the running (& failing) container (or scale the service to 0).

Make a backup before trying to recover from the corruption (replace your paths; -rp will do a recursive copy preserving permissions, timestamps…):

sudo cp -rp <original_postgres_data> <backup_postgres_data>

Reset the WAL

Run a bash command under the postgres data volume (replace by your volume name or bind path, also replace the postgres image version):

docker run -it --rm -u 999 -v <postgres_data_volume>:/var/lib/postgresql/data postgres:<version> bash

Then go to the data path & reset the WAL:

$ cd /var/lib/postgresql/data
$ pg_resetwal .
Write-ahead log reset

All is done, now you can run your postgres container normally.

No way

What to do if this does not work… recover your backup, because you do regular backups, don’t you?

References

  • https://hub.docker.com/_/postgres
  • https://www.postgresql.org/docs/current/app-pgresetwal.html

Comparte esto:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
Tags : Tags corrupted   docker   postgres   recover   WAL
Share
facebookShare on FacebooktwitterShare on TwitterpinterestShare on Pinterest
linkedinShare on LinkedinvkShare on VkredditShare on ReddittumblrShare on TumblrviadeoShare on ViadeobufferShare on BufferpocketShare on PocketwhatsappShare on WhatsappviberShare on ViberemailShare on EmailskypeShare on SkypediggShare on DiggmyspaceShare on MyspacebloggerShare on Blogger YahooMailShare on Yahoo mailtelegramShare on TelegramMessengerShare on Facebook Messenger gmailShare on GmailamazonShare on AmazonSMSShare on SMS
Post navigation
Previous post

Install kubectl on Ubuntu via APT repository

Next post

Back to the painting table

Emilio González Montaña

Related Posts

Categories Linux  Networking  Tecnología Recover corrupted Postgres DB WAL

Detachable screens to avoid SSH disconnections

Categories Linux  Networking  Tecnología Recover corrupted Postgres DB WAL

Expose WSL2 port to the network

Categories Tecnología Recover corrupted Postgres DB WAL

Install kubectl on Ubuntu via APT repository

Leave a Comment Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Detachable screens to avoid SSH disconnections
  • Expose WSL2 port to the network
  • Rosaleda (parque El Retiro, Madrid)
  • Back to the painting table
  • Recover corrupted Postgres DB WAL

Categories

  • Aficiones
  • AI
  • Bricolage
  • Data bases
  • Docker
  • Escenografía
  • Eventos
  • Fotografía
  • Hardware
  • Linux
  • Networking
  • Partidas
  • Proxmox
  • Sin categoría
  • Tecnología
  • Utils
  • Viajes
  • Virtualization
  • Warhammer
  • YAML

Tags

anthill (1) apt (5) cellular-automatons (1) ceph (2) context (1) conways-life (1) cortador (1) debian (3) docker (9) docker-compose.yml (4) docker-swarm (5) DRY (1) El Imperio (2) Enanos (2) escenografía (3) fotos (3) GlusterFS (1) Guerreros del Caos (2) informática (1) Linux (8) M.2 (1) Mac (1) Madrid (2) maqueta (2) MariaDB (2) miniaturas (4) MySQL (2) NFS (2) NVMe (1) partida (2) poliestireno (1) portainer (1) proxmox (2) rocas (1) Sony A65 (2) SSH (5) ssh-key (1) Ubuntu (8) update (2) volume (1) Warhammer (11) Windows (3) WSL (2) WSL2 (2) YAML (1)

Archives

  • June 2024
  • May 2024
  • April 2024
  • February 2024
  • January 2024
  • September 2023
  • August 2023
  • June 2023
  • December 2021
  • April 2021
  • May 2020
  • April 2020
  • March 2020
  • November 2019
  • July 2018
  • February 2017
  • June 2015
  • April 2014
  • April 2011
  • January 2011
  • July 2010
  • June 2010
  • March 2010
  • November 2009
  • June 2009
  • December 2008
  • November 2008
  • October 2008
  • June 2008
  • May 2008
  • October 2007

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Copyright © 2025 OCIO y TECnología - Powered by Nevothemes.
Offcanvas