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 1uWyWL-00475e-Mo for pgsql-general@arkaria.postgresql.org; Wed, 02 Jul 2025 14:33: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 1uWyWJ-0029Ng-PJ for pgsql-general@arkaria.postgresql.org; Wed, 02 Jul 2025 14:33: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 1uWyWJ-0029Jl-Ch for pgsql-general@lists.postgresql.org; Wed, 02 Jul 2025 14:33:08 +0000 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uWyWH-005Jn8-3B for pgsql-general@lists.postgresql.org; Wed, 02 Jul 2025 14:33:07 +0000 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-70b4e497d96so47399777b3.2 for ; Wed, 02 Jul 2025 07:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751466784; x=1752071584; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=PzzVY0nOs9TOpVCJmQl7pWy8pZs++puixGAN3diSdFs=; b=mykqES9oaJQfycEkihO2uzb0tg0QjNIzgvxrq29iybpJCxlQBk9P6z6qhPLwXd7qAq hKnsFjGibXWrx6YNCUgMImwY/4msYLiUR45YO3+B2HhQ9BW3YCkdrtxcjQeE6m3fE2Yk +U5fLd4N/HrZRFm1j8tZW5E8Cx8gF+vkGf0TqQbreHZrkNt4cEEFFGjYQsvvcfuLgegX mrJjfIP8MUiufonYr4a7Yfi1P5m/3d1XHk+p/sysgUdiwzbOUljlF+J7yWeKn/4c2+Pa /N/wv8tgLE/zaWaro4BIsjUlnRiOe2LZELXNnFGnYHRbGvdWrNb+NJJu4o1e0aQbOxz5 fhFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751466784; x=1752071584; h=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=PzzVY0nOs9TOpVCJmQl7pWy8pZs++puixGAN3diSdFs=; b=JS4aHqP9idkNGgshRN/nn1F4lGRKk0y3bp12H8ZBbCTTZ8VCrcEjsOv4F17g1drLtO W4kwplN05/fR5Er5gc+BX6mWLtR3qWAaUZlIFb6HaA18LAPMd9znrkyO0tiH5lEh21Iu zYmxPXtnjnIri6c2FCjoCa2r5cGwyzJRrobcwFlQKVVHDSA5xyKfUVXaNuwyiXAX8bgE /obOHkZPAawXHi6A3l2zW9K9EcJXbClp1O2T9692ylKvtdZDLEpwafM2qpJ2B9L4FU8R 0Y40t0nyfSe8SDtV3GkWWPBL+k1Mwdu2Uo/63XIpd6jwFBbgfzdHCKQ4KZrNqmA7dGtW cRFw== X-Gm-Message-State: AOJu0YwS+nptQbEwwuPq8Ri+m5dAHFZG2Xpvs1PUxobOBblf0Y0qh02A Q8GtaMjYXqa4/Nt04ZEhvU7Z6pGHrp/Cmffo2JsxIt1ysujPVfxofSp03pWY4EuiwLb3ChuGqRL yKjwrp3P55bYlB8vhK/TXNMoARimmbupXBhSF X-Gm-Gg: ASbGncvKl2as3er3UzuMAcfaPiAeCREpwTK2WWyQesaow7gMTZAYTp3Ir13e5uXU+eB 5Om5qrq/fP+3E9J5dMBzXBumsRTocL+6uYQruUln2pIdn6QXWVrhBx+QWv3dNPDeTJESzm1M86w RNPVrv1NQUlPXYSIfSy4uqS03SwwCUq7wxU/qM0TxObsbIzZ7C1qD+oV7nKa7BBJIB7ZiiewFc8 CWXZ3NDtLqFCNY= X-Google-Smtp-Source: AGHT+IFpxGKvDsbn0WLEcwUeiIQgGEIEJ3mA+Id+j0Dq4Zfws5oiw0cu08h39lI71Ok0+To4oDtRXQOCIf8KXD8Bbmk= X-Received: by 2002:a05:690c:6112:b0:712:d538:4e1 with SMTP id 00721157ae682-7164d4cde01mr42659437b3.35.1751466783552; Wed, 02 Jul 2025 07:33:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Franklin Anderson de Oliveira Souza Date: Wed, 2 Jul 2025 10:32:51 -0400 X-Gm-Features: Ac12FXwo0NSuZgPlg9ntML7ISxjRPjuXYS-QGdjLuYoqhTNBmIBdMvjEcSq0JVU Message-ID: Subject: Re: Simulate a PITR in postgresql 16 To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000007838440638f32318" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000007838440638f32318 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I don't know exactly what I did wrong but redoing what I described in the email worked perfectly! Thanks everyone! Enviado do Gmail para celular Em seg., 30 de jun. de 2025 =C3=A0s 15:35, Franklin Anderson de Oliveira So= uza < franklinbr@gmail.com> escreveu: > 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=3Dlocalhost --port=3D1111 > --username=3DUserReplication --slot=3Dslot_wals --verbose --no-loop > --directory=3D/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=3Dstream --checkpoint=3Dfast -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 =3D '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 > --0000000000007838440638f32318 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I don't know exactly what I did wrong but redoing what I desc= ribed in the email worked perfectly! Thanks everyone!


Enviado do Gmail para celular
=


Em seg., 30 de jun. de 2025 =C3=A0s 15:= 35, Franklin Anderson de Oliveira Souza <franklinbr@gmail.com> escreveu:
I'm trying to simulate a PITR in postgresql 16 with the f= ollowing 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' r= eplication;
select pg_create_physical_replication_slot('slot_wals');

4- Start pg_receivewal:
/usr/pgsql-16/bin/pg_receivewal --host=3Dlocalhost --port=3D1111
--username=3DUserReplication --slot=3Dslot_wals --verbose --no-loop
--directory=3D/data/wals

5- Load file csv on primary server
\COPY public.acme(hash) FROM '/data/csv/file_21444.csv' WITH (FORMA= T 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=3Dstream --checkpoint=3Dfast -D /data/base/

7- New load file csv on primary server
\COPY public.acme(hash) FROM '/data/csv/file_38629.csv' WITH (FORMA= T 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 =3D 'cp /data/wals/%f %p' # command to use to resto= re 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 o= r 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
--0000000000007838440638f32318--