From 63d2b2f386cf9d041aee51442fa6a1833c9f4660 Mon Sep 17 00:00:00 2001 From: Egor Voynov Date: Fri, 12 Apr 2024 09:56:31 +0200 Subject: [PATCH] pghoard: add history files to output file name check --- golang/pghoard_postgres_command_go.go | 2 +- pghoard/postgres_command.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/golang/pghoard_postgres_command_go.go b/golang/pghoard_postgres_command_go.go index 1b3bb852..cfa89df5 100644 --- a/golang/pghoard_postgres_command_go.go +++ b/golang/pghoard_postgres_command_go.go @@ -121,7 +121,7 @@ func restore_command(url string, output string, xlog string) (int, error) { } output_path = path.Join(cwd, output) } - xlogNameRe := regexp.MustCompile(`^[A-F0-9]{24}$`) + xlogNameRe := regexp.MustCompile(`'^([A-F0-9]{24}|[A-F0-9]{8}\.history)$'`) if xlogNameRe.MatchString(xlog) { // if file ".pghoard.prefetch" exists, just move it to destination xlogPrefetchPath := path.Join(path.Dir(output_path), xlog+".pghoard.prefetch") diff --git a/pghoard/postgres_command.py b/pghoard/postgres_command.py index 2eefb528..8a69badc 100644 --- a/pghoard/postgres_command.py +++ b/pghoard/postgres_command.py @@ -7,17 +7,16 @@ import argparse import os -import re import socket import sys import time from http.client import BadStatusLine, HTTPConnection, IncompleteRead +from pghoard.wal import TIMELINE_RE, WAL_RE from . import version PGHOARD_HOST = "127.0.0.1" PGHOARD_PORT = 16000 -XLOG_NAME_RE = re.compile("^[A-F0-9]{24}$") # When running restore_command PostgreSQL interprets exit codes 1..125 as "file not found errors" signalling # that there's no such WAL file from which PostgreSQL assumes that we've completed recovery. We never want to @@ -74,7 +73,7 @@ def restore_command(site, xlog, output, host=PGHOARD_HOST, port=PGHOARD_PORT, re # directory. Note that os.path.join strips preceding components if a new components starts with a # slash so it's still possible to use this with absolute paths. output_path = os.path.join(os.getcwd(), output) - if XLOG_NAME_RE.match(xlog): + if WAL_RE.match(xlog) or TIMELINE_RE.match(xlog): # if file ".pghoard.prefetch" exists, just move it to destination prefetch_path = os.path.join(os.path.dirname(output_path), xlog + ".pghoard.prefetch") if os.path.exists(prefetch_path):