fix: remove redundant backup command execution that runs database dump twice#4223
Open
kuishou68 wants to merge 1 commit intoDokploy:canaryfrom
Open
fix: remove redundant backup command execution that runs database dump twice#4223kuishou68 wants to merge 1 commit intoDokploy:canaryfrom
kuishou68 wants to merge 1 commit intoDokploy:canaryfrom
Conversation
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.
Summary
Fixes a bug where the database dump command is executed twice per backup operation, wasting resources and potentially uploading a different dump than the one that was "verified".
Problem
In
packages/server/src/utils/backups/utils.ts, thegetBackupCommandfunction generates a shell script that runs${backupCommand}(the database dump) twice:This means every backup:
The two dumps may capture different database states. The "verified" dump is never what gets uploaded.
Fix
Removed the redundant first dump block. The backup command now runs exactly once and streams directly into rclone. Error handling is preserved in the upload pipeline.
Files Changed
packages/server/src/utils/backups/utils.ts— removed the redundantBACKUP_OUTPUTtest execution blockCloses #4222
Greptile Summary
This PR fixes a real bug where the database dump command was executed twice per backup — once as a silent "test run" (output discarded) and again piped into rclone for upload — meaning the uploaded dump could reflect a different database state than the one that "passed" verification. The fix is correct: removing the first block lets the dump run once and stream directly into rclone, preserving
pipefailerror propagation.One minor follow-up worth considering: after the change,
backupCommand's stderr is not redirected intoUPLOAD_OUTPUT, so if the dump itself fails the log will show"Upload to S3 failed"with no useful context from the database tool. MergingbackupCommand's stderr into the captured stream (2>&1 | ${rcloneCommand}) would restore that diagnostic value.Confidence Score: 5/5
Comments Outside Diff (1)
packages/server/src/utils/backups/utils.ts, line 286-289 (link)With the redundant block removed, if
backupCommandfails (e.g. DB connection refused), the user still sees"❌ Error: Upload to S3 failed"andUPLOAD_OUTPUTwill only contain rclone's stderr (likely a broken-pipe message), not the actual database error.backupCommand's stderr is not redirected by2>&1 >/dev/nullhere — it escapes to the process's stderr and never reaches the log file.Consider splitting the check to preserve diagnostic clarity:
Or more portably, keep a single pipeline but improve error attribution:
Redirecting
backupCommand's stderr into the pipeline (2>&1) would capture dump errors inUPLOAD_OUTPUTand make the log actionable when diagnosing failures.Reviews (1): Last reviewed commit: "fix: remove redundant backup command exe..." | Re-trigger Greptile
(4/5) You can add custom instructions or style guidelines for the agent here!