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 1tdwr4-00AvDG-IN for pgsql-general@arkaria.postgresql.org; Fri, 31 Jan 2025 19:39:07 +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 1tdwr3-002G96-22 for pgsql-general@arkaria.postgresql.org; Fri, 31 Jan 2025 19:39:05 +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 1tdwr2-002G8y-M2 for pgsql-general@lists.postgresql.org; Fri, 31 Jan 2025 19:39:04 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tdwqz-002aJN-3C for pgsql-general@lists.postgresql.org; Fri, 31 Jan 2025 19:39:04 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5d7e3f1fdafso4591517a12.0 for ; Fri, 31 Jan 2025 11:39:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738352341; x=1738957141; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ZVm3zE3wJOyR9WtdsjRbJvXi+eipSJdDq8Zu3WHG/YA=; b=mUZU90NbsFq7499E5/ahll7GCRC+yw1jdYMrsRgRPFiEimwIVQ+fbwzoceIydBEcno CerTB1c4vnlZGJZVW4lTh84Goxrbvk7M44BPzFviBe7Kqv+ruaDGzzs/bwM5arilHqq5 noSQRLCYGIm2/YIADk36rkSTrUmG4OrOOPgynTan1w5wbiZkmhFsHIrheTVRE7Kli5uH zqvHazTtl5PJJh09BWCbY7O2CHem8PsJAed8yJM1aGYjOliopO6PkSgfmObxO5XAwBUp /ltnIgbWLiUYYCVmCNjsyM7U528PkZ3UUt+4tlC9ZepM2Y2uLXduXNFd6n95YMNIp6Jb 6Qcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738352341; x=1738957141; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZVm3zE3wJOyR9WtdsjRbJvXi+eipSJdDq8Zu3WHG/YA=; b=qHoW4VqSQDTqFCnqMntEA+XP0r5dnQhEP7/hh40bBaGgvPUVwWm7vlkF/3c5X7euiq F+8gi4f2qIYPtn8HMp04YNLruyHtRg5GD0ulMZPT07HOP08ZrAFTqsrG6wlOkvFGlbcb Ms7rT5elMdECnna4yFRDtF6zFp7oKPAWSgK8jz6LG7vh7dOl4Rur6moB4uP/FhtV8sjT 0KMx1J9biExFkcdLdq1dbd5+Y/DyZ71Y79garREZ0xb17XLEDvt/kJdyfYlFGHfahuk1 O0fg+t8sE3KFMLn/0U99Xqjn7d8OFF84AzX8PBkFJI6M7NV3UOKBYA4+7k+sR96aJJyg n9zg== X-Gm-Message-State: AOJu0YxgC/hTTcsLDOf01TgHBejncRtrl/6RZXPez+M6ChnfIzT6p935 62Q28W2d/2siB/ov3igCa/Z5K+/Bpb03eSBHGqsrITIb+EZ6Pc60cvRk/F0YPO0rkbG3zw4jQTf tbUtwmSmL/fweI/3rH9BnpAqnNKw= X-Gm-Gg: ASbGncuvMh8oqXnzMgANEdAfeEHWyYTkLu4RhtciPrpIFFMkGbC5+neNp955cvOioeU L1mL6FfICsWa//XT71LY2Cpsi6A5SpuLx3HGQvNNOLjZuBYnKlQMw1VI6uDjHknq9u4M7D4T1B/ rMYH5dUaJid4Svpx1I5lR+KxUNXrwhZEA= X-Google-Smtp-Source: AGHT+IHZJVAlA3t/QlIIrcNegMBwF2AWDTMswtDJphXiAhx+gj1SSaTOj02LwRTWOT4AcS6oOttBxxe1sUWcTVmPLSQ= X-Received: by 2002:a17:907:94c8:b0:aa6:b4b3:5925 with SMTP id a640c23a62f3a-ab6cfceaaf1mr1184492866b.14.1738352340676; Fri, 31 Jan 2025 11:39:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Koen De Groote Date: Fri, 31 Jan 2025 20:38:49 +0100 X-Gm-Features: AWEUYZk8qi0caZXVnU0dC5fMlgDbSlNFwArBYKiQms5-OvSfqDw34haDYa4JKFk Message-ID: Subject: Re: Postgres restore sometimes restores to a point 2 days in the past To: Laurenz Albe Cc: PostgreSQL General Content-Type: multipart/alternative; boundary="000000000000c2b9ae062d05b19d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c2b9ae062d05b19d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable No, it's meant to be an off-site restore, as to do a daily check if the restore actually works. Regards, Koen De Groote On Fri, Jan 31, 2025 at 2:30=E2=80=AFPM Laurenz Albe wrote: > On Fri, 2025-01-31 at 10:47 +0100, Koen De Groote wrote: > > I'm running postgres 16.6 > > > > My backup strategy is: basebackup and WAL archive. These get uploaded t= o > the cloud. > > > > The restore is on an isolated machine and is performed daily. It > downloads the > > basebackup, unpacks it, sets a recovery.signal, and a script is provide= d > as > > restore_command, to download the WAL archives %f and unpack them into %= p > > > > In the script, the final unpacking is simply "gzip -dc %f > %p". The gz > files > > are first checked with "gzip -t". > > > > If a WAL archive is asked that doesn't exist yet, the script naturally > cannot > > find it, and exits with status code 1. This is the end of the recovery. > > > > There are a few tables that are known to receive new entries multiple > times > > per day. However, the state of the recovery showed the latest item to b= e > 2 > > days in the past. Checking the live DB, there are an expected amount of > items > > since that ID. > > > > I checked the logs, the last WAL archive that got downloaded is indeed > the > > last one that was available. The one that failed to download on the > restore > > machine, was uploaded to the cloud 8 minutes later, according to the > upload > > logs on the live DB. > > > > The postgres logs themselves seem perfectly normal. It logs all these W= AL > > recoveries, switches the timeline, and becomes available. > > > > What could be going wrong? My main issue is that I don't know where to > start > > 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 > indeed > 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, whic= h > is > necessarily not totally up to date. > > Yours, > Laurenz Albe > --000000000000c2b9ae062d05b19d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
No, it's meant to be an off-site restore, as to do a d= aily check if the restore actually works.

Regards,
=
Koen De Groote

On Fri, Jan 31, 2025 at 2:30= =E2=80=AFPM Laurenz Albe <la= urenz.albe@cybertec.at> wrote:
On Fri, 2025-01-31 at 10:47 +0100, Koen De Groote wro= te:
> I'm running postgres 16.6
>
> My backup strategy is: basebackup and WAL archive. These get uploaded = to the cloud.
>
> The restore is on an isolated machine and is performed daily. It downl= oads the
> basebackup, unpacks it, sets a recovery.signal, and a script is provid= ed as
> restore_command, to download the WAL archives=C2=A0%f and unpack them = into %p
>
> In the script, the final unpacking is simply "gzip -dc %f > %p= ". The gz files
> are first checked with "gzip -t".
>
> If a WAL archive is asked that doesn't exist yet, the script natur= ally cannot
> find it, and exits with status code 1. This is the end of the recovery= .
>
> There are a few tables that are known to receive new entries multiple = times
> 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 o= f items
> since that ID.
>
> I checked the logs, the last WAL archive that got downloaded is indeed= the
> last one that was available. The one that failed to download on the re= store
> machine, was uploaded to the cloud 8 minutes later, according to the u= pload
> logs on the live DB.
>
> The postgres logs themselves seem perfectly normal. It logs all these = WAL
> recoveries, switches the timeline, and becomes available.
>
> What could be going wrong? My main issue is that I don't know wher= e to start
> 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&qu= ot; is indeed
the last one that was available, recovery did just what it is supposed to.<= br> 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
--000000000000c2b9ae062d05b19d--