Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tdr61-00A4W2-1o for pgsql-general@arkaria.postgresql.org; Fri, 31 Jan 2025 13:30:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tdr60-000W2j-7L for pgsql-general@arkaria.postgresql.org; Fri, 31 Jan 2025 13:30:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tdr5z-000W2a-S6 for pgsql-general@lists.postgresql.org; Fri, 31 Jan 2025 13:30:07 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tdr5x-002WJo-16 for pgsql-general@lists.postgresql.org; Fri, 31 Jan 2025 13:30:07 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-436ce2ab251so14188255e9.1 for ; Fri, 31 Jan 2025 05:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1738330205; x=1738935005; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=FpAX/Pad1eg0cFf9HVSCglyuJVMkaP3jJwm9LUUaWgQ=; b=TRYIqKNnM2fN4q7Y5o1ww2pqLWyt5dCvaJc8vureLsdzdGaHYIIDrWcl96vbWKdE1F YUqZUdQeb+H+hMIEDQQUP4UBgoYHRpT9nsFb/QtLHMzZLUq2FI7A+B7XOxUx7h/i9Kuf vbModw7fjGQTCoVs6ol7HxB++CwnRsIe2G1H2U17d8A/0mahwyQcGQHyFN0NAr1hJhWG zn144N7R5xu50fYfmq6lBFJJwaBZ2boZm4BWGxKxJwfpRxj1RBND1214Q+ctA8gu9evg 8FZ0aUGBTLIazZMeYLmuLMSnajcSW5pVhNB5QYmTduRPOfhaOhSJMuZVVA+q6K7hLbYj cIiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738330205; x=1738935005; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FpAX/Pad1eg0cFf9HVSCglyuJVMkaP3jJwm9LUUaWgQ=; b=sB3AxAQ5KzcyLkykEZ6X33Hd1lJtdnlu17Lddql2I30eXKlYEz8QFQDJJG8Ow76yNu ExWzY1jy9AdON+C2gW3s2YtexNkPQRQ47eQNlvu02Ja0nooLtBBNzS2VmImA02DOFsDZ d4SqCAKyIhQIuSB9AXN9E9AcgWc7p8Fa14Ah+sSxVAbc3h8XKOKvmR5DiB9l3jlcxzmX la3WVzXVTuTs5pGcM6XcGdVbBkNPzlRCS0lH4QRxwjkB6jiWes6TVJzeTHLBXrC0A4n4 XB9sIZ6EW4pFZyzTTQy0VvV9xBzO5OQ1NKpAwQ26pdxYYtRMrVX6vL5TrX9VWpAiV2u3 VkXw== X-Forwarded-Encrypted: i=1; AJvYcCUtaE8oJIScXFaOGaPivAB9s4ql0p77lgzUYnLDOuCGARtf9PqP/AJzqas2D8DSIYyKSiWtJWEI3AFN6Xc1@lists.postgresql.org X-Gm-Message-State: AOJu0YxKZQltZWyGldUX4QdDjdd6SakDo4znJXjyvvNilqD2zDzOHzVg KAiEs0vwvuKIQyvOMFBl8vcZuWNhdmqr19R7JP1epKp3KN9DNNBhX/6zp5zkavU= X-Gm-Gg: ASbGncujsqHiFqCzY/DHGIsjEX63pGxbG8YyNDjLsRj3HgNjZsb412hDwgyfv4tWcSL tPoGCyyX6I2t1iciQZJl6xdZ60lcHsWaQ+vzBPd4lDERttMYOyW+6AnAnyo5Ir1EPHzhZZurUlF DkX2mCGOBuxxjZzeaT2EPUu2pzoA2/JUHs1NHW+s1uSeDyh09qtv75EamYQotDabkw3saennYty Ocb6fQtJUAlTCBdJIe1m7uK41ktmsuuVrWe/z5vlAbnK17bxzYheB+7sqkNRntmOQ+bX6odDQLe fFD5Zoi34exX5E7ub6I3MTWm4MA/LQUG6NI2 X-Google-Smtp-Source: AGHT+IH+3jyj4MiSAvhKIfaLz7xuW/4nOqCYV0+cnojO4V8HY8xi1Uw61sWH40/KfG8SgOpi8b6FLw== X-Received: by 2002:a05:600c:1d1e:b0:436:a3a3:a70c with SMTP id 5b1f17b1804b1-438dc4214c3mr79676575e9.28.1738330202521; Fri, 31 Jan 2025 05:30:02 -0800 (PST) Received: from localhost.localdomain ([2001:871:5e:d239:ea99:d83b:9796:2a57]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438e23de772sm54947675e9.13.2025.01.31.05.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2025 05:30:02 -0800 (PST) Message-ID: Subject: Re: Postgres restore sometimes restores to a point 2 days in the past From: Laurenz Albe To: Koen De Groote , PostgreSQL General Date: Fri, 31 Jan 2025 14:30:01 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2025-01-31 at 10:47 +0100, Koen De Groote wrote: > I'm running postgres 16.6 >=20 > My backup strategy is: basebackup and WAL archive. These get uploaded to = the cloud. >=20 > The restore is on an isolated machine and is performed daily. It download= s the > basebackup, unpacks it, sets a recovery.signal, and a script is provided = as > restore_command, to download the WAL archives=C2=A0%f and unpack them int= o %p >=20 > In the script, the final unpacking is simply "gzip -dc %f > %p". The gz f= iles > are first checked with "gzip -t". >=20 > If a WAL archive is asked that doesn't exist yet, the script naturally ca= nnot > find it, and exits with status code 1. This is the end of the recovery. >=20 > There are a few tables that are known to receive new entries multiple tim= es > per day. However, the state of the recovery showed the latest item to be = 2 > days in the past. Checking the live DB, there are an expected amount of i= tems > since that ID. >=20 > I checked the logs, the last WAL archive that got downloaded is indeed th= e > last one that was available. The one that failed to download on the resto= re > machine, was uploaded to the cloud 8 minutes later, according to the uplo= ad > logs on the live DB. >=20 > The postgres logs themselves seem perfectly normal. It logs all these WAL > recoveries, switches the timeline, and becomes available. >=20 > What could be going wrong? My main issue is that I don't know where to st= art > looking, since nothing in the logs seems abnormal. I don't know, that all sounds like it is working as it should. If the last WAL archive that got downloaded by the "restore_command" is ind= eed the last one that was available, recovery did just what it is supposed to. If new WAL segments get archived later, that's too late. Perhaps you are looking for replication, not for restoring a backup, which = is necessarily not totally up to date. Yours, Laurenz Albe