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 1uWKI3-00CFei-BW for pgsql-general@arkaria.postgresql.org; Mon, 30 Jun 2025 19:35:43 +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 1uWKI0-001uYs-Fa for pgsql-general@arkaria.postgresql.org; Mon, 30 Jun 2025 19:35:41 +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 1uWKI0-001uYi-2s for pgsql-general@lists.postgresql.org; Mon, 30 Jun 2025 19:35:40 +0000 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uWKHy-004xmg-1d for pgsql-general@lists.postgresql.org; Mon, 30 Jun 2025 19:35:40 +0000 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-70e77831d68so26860047b3.2 for ; Mon, 30 Jun 2025 12:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751312136; x=1751916936; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=aGsnAlC0A8Bl9xNRAQULEQ7RbGR3PBBHpqBRq23y4iI=; b=kDUsvvTq3kBslesJyjFNOafZKjGKiH2vG6lS9DI581saL+NixHfuvqDSy52dK7Us5e DmFKxADKQMOd5+s6UGdc0CzVtSM3fVgC8Q5mRPhgv5nXMqqdMhXF5gTPxa4NYAQqXRH3 /gax2nyZNBrn77nkfm/qfBnKQHD8pOv9htkOHuZdR5XeTGI+GBLu4anpk+RFg2SBpSiV MjujqXarjshftHIbBg9UrHRD5+iEqIrs1JhScP4W6Tx189zoIFue9JqElvbAcffrLEOs uWyk/NtUcmkA2HjlaQwbl5DEYWzzayBPVFzGeRT9FvTOPhj1+ndfVtSDGKuauDoosDVu hMbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751312136; x=1751916936; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=aGsnAlC0A8Bl9xNRAQULEQ7RbGR3PBBHpqBRq23y4iI=; b=TKASxWCmZGRwyc5KHI2eCAIu3IUiv6XXGLRdSOlhVLSv6Dm7P7Fp+u7APB5rNVeYp6 FGsK1x5Ck6cLrHSz3fW7sJnozRe1YynSN1mmWtuqdyx1aQY9FtCT0i9ZmZO4yLAEpn1V H42tP10tvX43AC7SI1U1EXwoVTDHFv5I89r49sH/SPWMMkqc/9GQbirF1BizRwV/b+kS V79wXL6NJewF6LJ//OZS16dCvchJDWMaAU8WftP71Z+gV977kZafgdjippjBt2EQmNhu w+FSO2UIIl1YXEGpGCPJiwQvp3cxRDII5QFhI+ktTLlcKAZkS+kIMZhtMs8vO++Y2Sbe gxow== X-Gm-Message-State: AOJu0YwttpRb3HUrdPzx9EYs39a+pDYNtoDZGlZLG9eXAv9A+LJ/E8EE J5CsxR42w3KykFOmRWatR6jmeHcjQLx0dZLWcLVh2XA7ieuHDonzrDvCsY2UqOhm1iQgdEWne9s YPjVCcOqtoYwXb8NbpsUM+VUKiiJf2NU4QNxhXvA= X-Gm-Gg: ASbGncuMDC2yy4dv2ge00hZF0cNwahZnlrH7Wi26klvkEueRl3ccYGOxAoO0cew9gtw Gq5TOZscR8F3NfHm5I7FAqEZPxaOB2c8cGbcmRJRznNGKzj4YKOUc3JCG7GjG1//oRoDJzd3QtS LSN64tJMLO30nLkrHx8BBrElRDCBy18RQSxH3YNHWcUPWp X-Google-Smtp-Source: AGHT+IH/TQTQCogIqWIv/hcic0acE/oN998BzBQnyG6pCvDK7ALviSKSQ0tIJiXcJvNVoJQt7m6Ny3UYArg/f+4EWgA= X-Received: by 2002:a05:690c:b17:b0:70f:84c8:3105 with SMTP id 00721157ae682-715171ae8admr217213297b3.37.1751312136048; Mon, 30 Jun 2025 12:35:36 -0700 (PDT) MIME-Version: 1.0 From: Franklin Anderson de Oliveira Souza Date: Mon, 30 Jun 2025 15:35:24 -0400 X-Gm-Features: Ac12FXyXuMwBVXArFbZENrRYw7qvXr-dIuaaWO9YIg3I46v7rW5GOq8aHpW27-I Message-ID: Subject: Simulate a PITR in postgresql 16 To: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I'm trying to simulate a PITR in postgresql 16 with the following steps: directorys: /data/primary /data/base /data/wals /data/csv 1- Create cluster to primary postgresql: /usr/pgsql-16/bin/initd -D /data/primary 2- Start Cluster (1111 port) /usr/pgsql-16/bin/pg_ctl -D /data/primary start 3- Create Database, table, user and slot: create database "Foo"; \c Foo; create table public.acme(hash text); create role "UserReplication" with login password '123' replication; select pg_create_physical_replication_slot('slot_wals'); 4- Start pg_receivewal: /usr/pgsql-16/bin/pg_receivewal --host=localhost --port=1111 --username=UserReplication --slot=slot_wals --verbose --no-loop --directory=/data/wals 5- Load file csv on primary server \COPY public.acme(hash) FROM '/data/csv/file_21444.csv' WITH (FORMAT csv); example of file contents: $ head -n 10 /data/csv/file_21444.csv hash 0b035a242b54076056a59 4be85c5bcc5fe22191933 bb5632427c397b421b928 6ad913964b556d93379d7 99a072b776804e115bb2e 199834e3fe2d244e09543 ba296a09a91423401c901 9657bfcae2e017e9d6f42 0e2d4b2594006930da843 At this point wals were created in the /data/wals directory by pg_receivewal due to the applied load of item 5 on the primary server. 6- Create pg_basebackup pg_basebackup -U UserReplication -h localhost -p1111 -P -v --wal-method=stream --checkpoint=fast -D /data/base/ 7- New load file csv on primary server \COPY public.acme(hash) FROM '/data/csv/file_38629.csv' WITH (FORMAT csv); more wals were created by pg_receivewal with new data load. Now I will start the cluster generated by pg_basebackup with the restore_command parameter configured to feed on the wals logs generated from the last data load, thus leaving it updated with the same data as the primary: 8- Restore Command Parameter restore_command = 'cp /data/wals/%f %p' # command to use to restore an archived WAL file and touch /data/base/recovery.signal 9- Start Cluster (2222 port) /usr/pgsql-16/bin/pg_ctl -D /data/base start but when I see the logs I have a surprise ----------------- LOG: starting PostgreSQL 16.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22), 64-bit LOG: listening on IPv6 address "::1", port 2222 LOG: listening on IPv4 address "127.0.0.1", port 2222 LOG: listening on Unix socket "/run/postgresql/.s.PGSQL.2222" LOG: listening on Unix socket "/tmp/.s.PGSQL.2222" LOG: database system was shut down at 2025-06-30 12:15:28 -04 cp: cannot stat '/dados/temp/wals/00000002.history': No such file or directory ----------------- The restore_command requires the .history file but it does not exist in any of the clusters in this simple test, which is wrong in this example ? Tanks -- foobar