feat(compression): allow configuring the Kopia compression policy - #189
Open
gabriele-wolfox wants to merge 3 commits into
Open
feat(compression): allow configuring the Kopia compression policy#189gabriele-wolfox wants to merge 3 commits into
gabriele-wolfox wants to merge 3 commits into
Conversation
gabriele-wolfox
force-pushed
the
dev/126
branch
5 times, most recently
from
August 31, 2026 07:48
c1b9f04 to
e424a8d
Compare
Kopia repositories were created without a compression policy, so base backup data was stored uncompressed. Allow users to configure a compression policy repository-wide on the Server (applied to the global Kopia policy at server start) and per-cluster on the PluginConfiguration (applied to the cluster's own source, overriding the global policy). Both tier1 and tier2 are covered: tier1 is set through the Kopia server during the backup, while tier2 travels over gRPC and is applied by the backup consumer before the relay. The policy exposes the compression algorithm plus the optional minSize and maxSize bounds (in bytes) that restrict which files are compressed. Kopia's only-compress and never-compress extension lists are left out on purpose: they select files by extension, which does not fit a PostgreSQL data directory (relation files are numeric and carry no meaningful extension), and WAL files are compressed on a separate path regardless. Closes #126 Assisted-by: Claude Signed-off-by: Gabriele Quaresima <gabriele.quaresima@enterprisedb.com>
The policy builder emitted `--compression-min-size` and `--compression-max-size` only for non-zero values, so a bound written to the Kopia repository could never be removed: no value of the configuration field produced a flag that reset it, and files outside the stale range silently stayed uncompressed. Both bounds are now always emitted, with zero rendered as `inherit`, which Kopia resets to the value inherited from the parent policy. Document that removing the whole `compression` section still leaves the stored policy in place, and that `algorithm: none` is the way to stop compressing. Refs #126 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
A `minSize` above a non-zero `maxSize` matches no file at all: Kopia accepts the policy and then skips compression for every file, so the resource reported compression as enabled while nothing was compressed. The range is now validated in the client policy, in the tier1 and tier2 server configuration, and through a CEL rule on the shared CRD type, so an inconsistent range is refused at admission. The check runs even when no algorithm is set, because the size bounds are applied independently of it. Refs #126 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
armru
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Kopia repositories were created without a compression policy, so base backup
data was stored uncompressed. This lets users configure Kopia compression for
base backups, both globally and per cluster.
Configuration
Compression can be set at two levels, following Kopia's policy inheritance
(a per-cluster policy overrides the global one for that cluster's source):
Server, underspec.tier1.compressionand
spec.tier2.compression. Applied to Kopia's global policy when theserver starts.
PluginConfiguration, underspec.tier1.compressionand
spec.tier2.compression. Applied to the cluster's own source.Each policy exposes:
algorithm: any Kopia compressor (e.g.zstd,s2-default,gzip) ornoneto disable compression.minSize/maxSize(optional, bytes): restrict compression to files withina size range.
Both tier1 and tier2 are covered. Compression takes effect on the next backup;
existing backups are not recompressed.
Example:
Out of scope
Kopia's
only-compress/never-compressextension lists are not exposed:they select files by extension, which does not fit a PostgreSQL data directory
(relation files are numeric), and WAL files are compressed separately.
Testing
A new e2e (
compression_test.go) sets a global policy on theServerand adifferent per-cluster policy on the
PluginConfiguration, runs a backup, andasserts via
kopia policy showthat both the--globalanduser@hostpolicies carry the expected algorithm and
minSizeon tier1 and tier2. Docs,CRDs, Helm chart, and generated API reference are updated.
Closes #126
Assisted-by: Claude