# Basebackup failing after configuring pg\_tde || PostgreSQL 16

**URL:** <https://forums.percona.com/t/basebackup-failing-after-configuring-pg-tde-postgresql-16/34495>\
**Category:** PostgreSQL\
**Created:** [October 21, 2024, 12:32pm UTC](https://forums.percona.com/t/basebackup-failing-after-configuring-pg-tde-postgresql-16/34495 "2024-10-21T12:32:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![amulla](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@amulla](https://forums.percona.com/u/amulla)\
**Post date:** [October 21, 2024, 12:32pm UTC](https://forums.percona.com/t/basebackup-failing-after-configuring-pg-tde-postgresql-16/34495/1 "2024-10-21T12:32:57Z")

</div>

I have followed below documentation to configure pg\_tde in RHEL 8 with PG version 16. [pg\_tde documentation](https://percona.github.io/pg_tde/main/)

After enabling and configuring pg\_tde key provider and master key . pg\_basebackup is getting failed with below error

```auto
[postgres@hostname postgres]$ pg_basebackup -D bkp_test -R -X stream -v
pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
pg_basebackup: write-ahead log start point: 0/14000028 on timeline 1
pg_basebackup: starting background WAL receiver
pg_basebackup: created temporary replication slot "pg_basebackup_1391250"
WARNING: aborting backup due to backend exiting before pg_backup_stop was called
pg_basebackup: error: COPY stream ended before last file was finished
pg_basebackup: removing contents of data directory "bkp_test"

```

In the logs I can see below error.

```auto
2024-10-18 07:55:21.132 EDT [1241049] LOG: checkpoint starting: force wait
2024-10-18 07:55:21.136 EDT [1241049] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 1 recycled; write=0.001 s, sync=0.001 s, total=0.004 s; sync files=0, longest=0.000 s, average=0.000 s; distance=16384 kB, estimate=27000 kB; lsn=0/14000060, redo lsn=0/14000028
2024-10-18 07:55:21.205 EDT [1391249] WARNING: aborting backup due to backend exiting before pg_backup_stop was called
2024-10-18 07:55:21.205 EDT [1391249] ERROR: invalid segment number 0 in file "pg_tde.map"
2024-10-18 07:55:21.205 EDT [1391249] STATEMENT: BASE_BACKUP ( LABEL 'pg_basebackup base backup', PROGRESS, WAIT 0, MANIFEST 'yes', TARGET 'client')
2024-10-18 07:55:21.221 EDT [1391250] LOG: unexpected EOF on standby connection
2024-10-18 07:55:21.221 EDT [1391250] STATEMENT: START_REPLICATION SLOT "pg_basebackup_1391250" 0/14000000 TIMELINE 1

```

After loading shared library pg\_tde on server level and configuring master key for specific DB level, I can see below files in base directory that is creating issue. but unable to understand .

```auto
./16505/pg_tde.map
./16505/pg_tde.dat

```

below are the databases with OID.

```auto
test=# select oid,datname from pg_database;
  oid | datname
-------+-----------
     5 | postgres
     1 | template1
     4 | template0
 16505 | test
(4 rows)

```

Thanks for your support team. I had to post here as I am not getting any article online for this. there might be some issue with my setup I am not sure.

---

<div class="post-metadata">

**Author:** ![Andrew\_Pogrebnoi](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/andrew_pogrebnoi/32/77_2.png) [@Andrew\_Pogrebnoi](https://forums.percona.com/u/Andrew_Pogrebnoi)\
**Post date:** [October 21, 2024, 2:52pm UTC](https://forums.percona.com/t/basebackup-failing-after-configuring-pg-tde-postgresql-16/34495/2 "2024-10-21T14:52:35Z")

</div>

Hi there.  
pg\_tde.map and pg\_tde.dat are used by pg\_tde to store principal keys metadata and encrypted internal keys. Unfortunately, postgres treats these as files that need checksum validation and tries to do that but fails. We have fixed this in our [Percona Server for PostgreSQL](https://docs.percona.com/postgresql/17/postgresql-server.html) but it’s only available in v 17. So if you want to use pg\_tde with the community version of PostgreSQL, you have to disable checksums for pg\_basebackup (`--no-verify-checksums`)

---

<div class="post-metadata">

**Author:** ![amulla](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@amulla](https://forums.percona.com/u/amulla)\
**Post date:** [October 21, 2024, 3:49pm UTC](https://forums.percona.com/t/basebackup-failing-after-configuring-pg-tde-postgresql-16/34495/3 "2024-10-21T15:49:37Z")

</div>

@Andrew_Pogrebnoi Thank you so much for you help on this.

Current document mentioned principal key but in setup we have master key naming conventions.

SELECT pg\_tde\_set\_principal\_key(‘name-of-the-principal-key’, ‘provider-name’); this is in documentation but if you check functions after configuring we need to set pg\_tde\_set\_master\_key … then only working. could you please let me know when this is going to fix ? currently function syntax written in documentation are diff than actual downloaded setup .

thanks for you help

---

<div class="post-metadata">

**Author:** ![Andrew\_Pogrebnoi](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/andrew_pogrebnoi/32/77_2.png) [@Andrew\_Pogrebnoi](https://forums.percona.com/u/Andrew_Pogrebnoi)\
**Post date:** [October 22, 2024, 11:45am UTC](https://forums.percona.com/t/basebackup-failing-after-configuring-pg-tde-postgresql-16/34495/4 "2024-10-22T11:45:37Z")

</div>

How do you install pg\_tde? When did you installed/updated it last time?  
We merged a [PR](https://github.com/percona/pg_tde/pull/228) with the renaming back in June and everything should work as the documentation states.

---

<div class="post-metadata">

**Author:** ![amulla](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@amulla](https://forums.percona.com/u/amulla)\
**Post date:** [October 22, 2024, 12:23pm UTC](https://forums.percona.com/t/basebackup-failing-after-configuring-pg-tde-postgresql-16/34495/5 "2024-10-22T12:23:22Z")

</div>

Hi @Andrew_Pogrebnoi Thanks for your help on this. we installed in sept only. I will recheck and try . --We used this setup → sudo yum -y install [https://repo.percona.com/yum/percona-release-latest.noarch.rpm](https://repo.percona.com/yum/percona-release-latest.noarch.rpm)

---

<div class="post-metadata">

**Author:** ![Andrew\_Pogrebnoi](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/andrew_pogrebnoi/32/77_2.png) [@Andrew\_Pogrebnoi](https://forums.percona.com/u/Andrew_Pogrebnoi)\
**Post date:** [October 22, 2024, 12:59pm UTC](https://forums.percona.com/t/basebackup-failing-after-configuring-pg-tde-postgresql-16/34495/6 "2024-10-22T12:59:02Z")

</div>

@amulla sept build should have a fix for this issue. Another thing, just reinstalling the extension won’t help in this case as it is currently doesn’t update .sql manifests (which contains declaration of the functions). You have to also explicitly drop and create the extension:

```auto
> DROP EXTENSION pg_tde;
> CREATE EXTENSION pg_tde;

```

We’ll make proper upgrade facilities later on but for now this is the only way.
