fix: refresh server IP after web server restore#4542
Open
NoelisTired wants to merge 1 commit into
Open
Conversation
When restoring a Dokploy web server backup, the database is restored as-is, which means `webServerSettings.serverIp` keeps the IP of the machine the backup was taken on. After restoring onto a different host the dashboard kept showing the old "Server IP". Re-detect the current host's public IP with `getPublicIpWithFallback` once the database restore finishes and persist it via `updateWebServerSettings`, mirroring how the IP is detected during initial setup. If detection fails the stored value is left untouched and a warning is emitted so it can be updated manually. Adds tests covering the success, detection-failure, and ordering cases.
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
When restoring a Dokploy web server backup, the PostgreSQL database is restored as-is. That database row (
webServerSettings) contains theserverIpof the machine the backup was originally taken on, so after restoring a backup onto a different host the dashboard keeps displaying the old "Server IP" indefinitely.This PR re-detects the current host's public IP once the database restore finishes and persists it, so the restored instance reflects the machine it is actually running on.
How
In
restoreWebServerBackup(packages/server/src/utils/restore/web-server.ts), right after the databasepg_restorecompletes:getPublicIpWithFallback()(the same helper used during initial setup inlib/auth.ts).updateWebServerSettings({ serverIp }).This mirrors exactly how
serverIpis populated when the first admin is created, so there's no new detection logic — just reuse of the existing path at the right moment.Why this scope
Kept intentionally narrow to the reported "Server IP stays stale after restore" bug. Other instance-specific values that are also restored from the backup (metrics callback URLs, SSH keys, registry URLs, bind-mount/cert paths, ACME data) can be stale after restoring onto a new host too, but those are separate concerns and are out of scope here.
Testing
apps/dokploy/__test__/restore/web-server.test.ts(vitest) covering:null.pg_restorehas run.pnpm --filter=@dokploy/server typecheckpasses.biome checkclean on the changed files.__test__/restore,__test__/wss/utils,__test__/utils/backups) passes — 28/28.