Repository navigation
feat(volume-backups): add gzip compression to volume backups - #5206
anxo-outeiral wants to merge 3 commits into
Conversation
| // delete all the .tar.gz files | ||
| const command = `rm -rf ${volumeBackupPath}/*.tar.gz`; |
There was a problem hiding this comment.
Legacy archives escape cleanup
If an interrupted pre-upgrade backup leaves a local .tar archive, the changed failure handler matches only .tar.gz, leaving the legacy archive on disk indefinitely and consuming server storage.
Knowledge Base Used: Backups and restore
Volume backups were creating uncompressed .tar archives using tar cvf. This changes to tar czf (gzip compression), producing .tar.gz files that are significantly smaller for compressible data (text, JSON, SQLite, logs), reducing S3 storage costs. Changes: - backup.ts: tar cvf -> tar czf, extension .tar -> .tar.gz - utils.ts: retention filter *.tar -> *.tar.gz, error cleanup updated Compatibility: - gzip is pre-installed in the ubuntu image used for volume backups - tar xvf in restore auto-detects gzip, so existing restore logic works for both old .tar and new .tar.gz files - Old .tar files in S3 are not affected by the new retention policy (which now filters *.tar.gz); they require manual cleanup Closes Dokploy#3566
d01baef to
76615ad
Compare
|
failed backup cleanup still leaves legacy local .tar archives behind |
| // delete all the .tar files | ||
| const command = `rm -rf ${volumeBackupPath}/*.tar`; | ||
| // delete all the .tar and .tar.gz files (including legacy .tar from pre-upgrade) | ||
| const command = `rm -rf ${volumeBackupPath}/*.tar*`; |
There was a problem hiding this comment.
Cleanup deletes concurrent archives
If two runs of the same volume-backup record overlap, a failure in one run deletes every *.tar* file in their shared directory, including the other run's in-progress .tar.gz archive, causing its tar creation or upload to fail as well.
Knowledge Base Used: Backups and restore
There was a problem hiding this comment.
@greptile-apps it's a valid concern. I think this was already discussed in the original fix PR (#2652). Here's the context:
Each volume backup job writes to its own directory: ${VOLUME_BACKUPS_PATH}/${volumeBackup.appName}/ — so jobs for different backup records are isolated. When @Siumauricio reviewed the original fix he confirmed: "when you create a new volume backup job it creates its own directory, so they are isolated."
That said, two schedules targeting the same service (same appName) would share a directory and could theoretically collide if they overlap. That's a known limitation of the locking mechanism and out of scope for this PR, but worth addressing in a follow-up (e.g. by using the in-progress backup filename as the cleanup target instead of a broad glob).
Should I add a note about this in the PR description as a known limitation, or do you think it's worth blocking on?
There was a problem hiding this comment.
That context is valid. Given that each backup record normally has its own ${VOLUME_BACKUPS_PATH}/${volumeBackup.appName} directory, I would not block this PR solely on the concurrency concern—especially since overlapping schedules for the same service are a pre-existing limitation rather than something introduced by gzip.
I would add a short “Known limitation” note to the PR description and track the follow-up. Be precise: overlapping backups that resolve to the same appName can share the directory, and failure cleanup currently uses a broad *.tar* glob that may remove another run’s archive. The follow-up should clean up only the archive created by the failing run, ideally by passing the exact backup path into the failure cleanup.
Recommendation: downgrade this from a merge blocker to a non-blocking follow-up, provided per-record directory isolation is confirmed for all supported service types. The broader glob is still worth fixing separately because it makes that existing race affect the new .tar.gz files.
Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.
There was a problem hiding this comment.
@greptile-apps confirmed! Directory isolation (${VOLUME_BACKUPS_PATH}/${volumeBackup.appName}/) applies consistently across all service types: application, compose, postgres, mysql, mariadb, mongo, redis, and libsql. The broader cleanup glob is a pre-existing issue and worth addressing separately in a follow-up.
I've also added a "Known limitations" section to the PR description to document this
There was a problem hiding this comment.
Confirmed. Since directory isolation applies consistently across all supported service types, this is not a merge blocker for this PR. Documenting the shared-appName concurrency case as a known limitation is appropriate; the broad cleanup glob can be addressed separately by targeting the failing run’s exact archive path.
What is this PR about?
Volume backups currently create uncompressed
.tararchives usingtar cvf. This means that for data that compresses well (SQLite databases, JSON, text logs, configuration files), the backup stored in S3 is the same size as the original volume — wasting storage space and increasing S3 costs.This PR changes to
tar czf(gzip compression), producing.tar.gzfiles that are significantly smaller for compressible data, reducing S3 storage costs and transfer time.Changes
backup.ts: Changedtar cvf→tar czfand extension.tar→.tar.gzutils.ts: Updated retention filter--include "*.tar"→--include "*.tar.gz"and error cleanup*.tar→*.tar.gzCompatibility
ubuntuDocker image used for volume backups — no additional dependencies or runtime package installation neededtar xvfinrestore.tsauto-detects gzip compression, so existing restore logic continues to work for both old.tarand new.tar.gzfiles without any changes.tarfiles already in S3 are not affected by the new retention policy (which now filters*.tar.gz); they will need manual cleanupTesting
Tested locally with a full development stack (Dokploy dev server + MinIO as local S3 destination + Docker Swarm):
gzipis available in theubuntuDocker image.tar.gzfile appears in S3 destination (MinIO)filecommand reportsgzip compressed data, from Unix.tar.gzbackup successfullykeepLatestCountretention works with.tar.gzextensiontar xvfrestores both.tarand.tar.gzCompression results (13.4MB of text/JSON/SQL data):
Checklist
Before submitting this PR, please make sure that:
canarybranch.Known limitations
appName) share a directory, and the error cleanup uses a broad*.tar*glob that may delete another run's in-progress archive. A follow-up should clean up only the specific archive created by the failing run.Issues related (if applicable)
Closes #3566
Screenshots (if applicable)
Backup log showing
tar czfand.tar.gz:The PR is not yet safe to merge because failure cleanup can delete a concurrent backup run's in-progress archive.
Summary
.tar.gzfiles.Reviews (3) · Last reviewed commit: "fix(volume-backups): clean up legacy .ta..."