Repository navigation
A restore with --force replaces the data directory, so an existing data dir is overwritten instead of refused after the database is already restored - #1444
Closed
rudycelekli wants to merge 1 commit into
Conversation
…ta dir is overwritten instead of refused after the database is already restored Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This was referenced Oct 26, 2026
Contributor
|
Thanks, and sorry this one was raced: #1449 fixed the same ordering (the data directory is checked before the database is changed) and is now merged, so I'm closing this as superseded. |
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.
Why
utopia restore --forceis accepted and printed in the plan, then ignored.apply_restorerefuses a non-empty target data directory with "pass --force to overwrite" whether or not the flag was passed. That check runs afterpg_restore --clean, so the database has already been replaced and the files are left as they were. The flag cannot do the one thing its error message tells the operator to do.What changes
run_restorepassesargs.forceintoapply_restore. A non-empty target is still refused without the flag, and the old files stay. With the flag, the target directory is removed before the archive's data directory is copied in, so the result is the archive's files and not a mix of both.How it was checked
force_replaces_a_non_empty_data_dir, builds an archive withdata/new.txt, points--target-data-dirat a directory that already holdsold.txt, and uses/usr/bin/trueaspg_restore. Without--forcethe restore is refused andold.txtremains. With--force,new.txtis the archive's bytes andold.txtis gone.--force should replace the data dir: target data dir … is non-empty; pass --force to overwrite.cargo test -p utopia-cli --bin utopia: 16 passed.cargo fmt -p utopia-cli --checkandcargo clippy -p utopia-cli --all-targets -- -D warningspass.Before review
git commit -s)cargo fmt --all --check,cargo clippyandcargo testpass for the touched crate