Skip to content

ADBM-3251: Implement decompression for pgbackrest repo-get#109

Merged
dkovalev1 merged 22 commits into
2.54-cifrom
ADBM-3251
Jul 14, 2026
Merged

ADBM-3251: Implement decompression for pgbackrest repo-get#109
dkovalev1 merged 22 commits into
2.54-cifrom
ADBM-3251

Conversation

@dkovalev1

@dkovalev1 dkovalev1 commented Jul 2, 2026

Copy link
Copy Markdown

Implement optional decompression for repo-get command

This commit introduces optional flag --decompress. If specified, pgBackRest automatically decompresses the file before writing to stdout. The compression algorithm is determined from the backup manifest (the same algorithm that was used when the backup was created). If decompression fails (e.g., the file is not compressed or the manifest entry is missing), an error is returned. Without this flag, the raw (possibly compressed) content is output.

Also, it is possible to override the compression algorithm specified in the backup manifest using compress-type option.

@dkovalev1 dkovalev1 changed the title [DRAFT] ADBM-3251: Implement decompression for pgbackrest repo-get ADBM-3251: Implement decompression for pgbackrest repo-get Jul 7, 2026
@hilltracer hilltracer self-requested a review July 8, 2026 11:26
hilltracer

This comment was marked as resolved.

@dkovalev1

Copy link
Copy Markdown
Author

The main path works fine for me:
spoiler

But I have problem when encryption is enabled:
spoiler

In SRS we have

The file is read from the repository storage. If encryption is enabled, it is automatically decrypted (transparently).

So, looks like it's the problem

yes, and it took to refactor the whole patch to fix it.

Comment thread src/build/config/config.yaml
Comment thread src/command/repo/get.c Outdated
Comment thread src/build/help/help.xml Outdated
@hilltracer

This comment was marked as resolved.

Comment thread test/src/module/command/repoTest.c Outdated
Comment thread test/src/module/command/repoTest.c
@dkovalev1

Copy link
Copy Markdown
Author

It's still doesn't work for encrypted archive files =(
spoiler

It appears that to get a backup manifest, a different pass is needed, no the same as for archive info and the file. Made passwords processing more complicated.

Also, it appears that this case can not be reproduced in the unit tests, as it depends heavily on the logic from the backup command and archiving subsystem. I suggest to leave this case for manual testing.

@hilltracer

This comment was marked as resolved.

Comment thread src/build/help/help.xml
@dkovalev1

dkovalev1 commented Jul 13, 2026

Copy link
Copy Markdown
Author

But I have problem with REPO:BACKUP and REPO:ARCHIVE in encrypted repo. =(

This is the case where stanza is really required. Added one more check.

Spoiler
rm -rf /home/denis/.data/pgbackrest-enc
mkdir -p /home/denis/.data/pgbackrest-enc
cat >/tmp/pgbackrest-enc.conf <<EOF
[global]
fork=GPDB
log-level-console=info
repo1-path=/home/denis/.data/pgbackrest-enc
repo1-cipher-type=aes-256-cbc
repo1-cipher-pass=test-passphrase
compress-type=gz
archive-check=n

[seg0]
pg1-path=/home/denis/arena/gg6/gpAux/gpdemo/datadirs/dbfast1/demoDataDir0/
pg1-port=6002
EOF
gpconfig -c archive_mode -v on
gpconfig -c archive_command --skipvalidation -v "'PGOPTIONS=\"-c gp_session_role=utility\" /home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --stanza=seg%c archive-push %p'"
gpstop -afr
PGOPTIONS="-c gp_session_role=utility" \
/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --stanza=seg0 stanza-create

PGOPTIONS="-c gp_session_role=utility" \
/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --stanza=seg0 backup --type=full --no-archive-check
ls -1 /home/denis/.data/pgbackrest-enc/backup/seg0
# 20260713-191332F

export ENC_SET="20260713-191332F"

find /home/denis/.data/pgbackrest-enc/backup/seg0/$ENC_SET -type f -name '*.gz' | head -1
# /home/denis/.data/pgbackrest-enc/backup/seg0/20260713-191332F/pg_data/pg_hba.conf.gz

export FILE_NAME=pg_data/pg_hba.conf.gz

/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --stanza=seg0 \
repo-get "backup/seg0/$ENC_SET/$FILE_NAME" | gzip -cd | head -1
# 9.4

/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --stanza=seg0 --set=$ENC_SET \
repo-get --decompress "backup/seg0/$ENC_SET/$FILE_NAME"
# 9.4

/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --stanza=seg0 --set=$ENC_SET \
repo-get --decompress "<REPO:BACKUP>/$ENC_SET/$FILE_NAME"
# 9.4

/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --compress-type=gz \
repo-get --decompress "<REPO:BACKUP>/seg0/$ENC_SET/$FILE_NAME"

# error:
# 2026-07-13 19:53:29.623 P00  ERROR: [043]: stanza required

The same for archive command.

Spoiler
create extension gp_pitr;
select gp_create_restore_point('backup1');
select gp_switch_wal();
ls  /home/denis/.data/pgbackrest-enc/archive/seg0/9.4-1/0000000100000000
#000000010000000000000001-7d340d277852ffddd5831094608b7073a202c314.gz
#000000010000000000000002-e69f49ad5b5453c52083872b7bb117c6861e4720.gz

export ARCH_FILE="archive/seg0/9.4-1/0000000100000000/000000010000000000000001-7d340d277852ffddd5831094608b7073a202c314.gz"
export ARCH_FILE_ALIAS="<REPO:ARCHIVE>/seg0/9.4-1/0000000100000000/000000010000000000000001-7d340d277852ffddd5831094608b7073a202c314.gz"
export ARCH_FILE_ALIAS_2="<REPO:ARCHIVE>/9.4-1/0000000100000000/000000010000000000000001-7d340d277852ffddd5831094608b7073a202c314.gz"

/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --stanza=seg0 \
repo-get "$ARCH_FILE" | gzip -cd | head -3

# ~����l�Tj�M�
# ����J@v1�@v1 �)�2�  ����� ���
#                              @gp_pitr
# �1.17
# 
#       +0plpgsql

ls -1 /home/denis/.data/pgbackrest-enc/backup/seg0
# 20260713-191332F

export ENC_SET="20260713-191332F"

/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --stanza=seg0 --set="$ENC_SET" \
repo-get --decompress "$ARCH_FILE" | head -3

# ~����l�Tj�M�
# ����J@v1�@v1 �)�2�  ����� ���
#                              @gp_pitr
# �1.17
# 
#       +0plpgsql

/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --stanza=seg0 --set="$ENC_SET" \
repo-get --decompress "$ARCH_FILE_ALIAS_2" | head -3
# ~����l�Tj�M�
# ����J@v1�@v1 �)�2�  ����� ���
#                              @gp_pitr
# �1.17
# 
#       +0plpgsql

/home/denis/arena/pgbackrest/build/src/pgbackrest --config=/tmp/pgbackrest-enc.conf --compress-type=gz \
repo-get --decompress "$ARCH_FILE_ALIAS" | head -3

# error:
#
# 2026-07-13 19:57:21.276 P00  ERROR: [043]: stanza required

Comment thread src/build/help/help.xml Outdated
@ShapatinAA

This comment was marked as resolved.

@hilltracer

hilltracer commented Jul 14, 2026

Copy link
Copy Markdown

Do I need to specify something? My command is failing:

did you define alias with /9.4-1?

ARCH_FILE_ALIAS_2="<REPO:ARCHIVE>/9.4-1/...

@ShapatinAA

Copy link
Copy Markdown

did you define alias with /9.4-1?

No, I defined nothing.

@dkovalev1 dkovalev1 merged commit bf91bcc into 2.54-ci Jul 14, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants