Skip to content

Feat: add optional AES-256-CTR encryption for S3 backup files - #178

Open
ClaReQurv wants to merge 4 commits into
eduardolat:developfrom
ReQurv:main
Open

Feat: add optional AES-256-CTR encryption for S3 backup files#178
ClaReQurv wants to merge 4 commits into
eduardolat:developfrom
ReQurv:main

Conversation

@ClaReQurv

Copy link
Copy Markdown

Summary

Adds optional file-level encryption for database dump files before uploading them to S3 storage. When PBW_FILES_ENCRYPTION_KEY is set, dump files are encrypted with AES-256-CTR before upload and automatically decrypted during restore.

Changes

  • .env.example – Added PBW_FILES_ENCRYPTION_KEY environment variable documentation
  • internal/config/env.go – Added PBW_FILES_ENCRYPTION_KEY as an optional env config field
  • internal/util/cryptoutil/cipher.go – New cryptoutil package providing:
  • EncryptReader – wraps an io.Reader with AES-256-CTR encryption (prepends a random 16-byte nonce)
  • DecryptFile – decrypts a file in-place using the provided passphrase
  • internal/integration/storage/s3.go – S3Upload now encrypts the file content before sending to S3 when an encryption key is provided
  • internal/integration/postgres/postgres.go – RestoreZip decrypts the ZIP file before attempting to unzip it
  • internal/service/executions/run_execution.go – Passes PBW_FILES_ENCRYPTION_KEY to S3Upload
  • internal/service/restorations/run_restoration.go – Passes PBW_FILES_ENCRYPTION_KEY to RestoreZip

Backward Compatibility

Fully backward compatible. When PBW_FILES_ENCRYPTION_KEY is empty (default), behavior is identical to before — no encryption is applied.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9c9f421b-8b89-4242-a107-e9c7fac34000

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

2 participants