[Bug] Rolling an update back overwrites pegaprox/api/settings.py with the launcher, and the service no longer starts
Describe the bug
POST /api/pegaprox/update/rollback with a backup made by the updater answers success: true. It replaces pegaprox/api/settings.py with a copy of pegaprox_multi_cluster.py, and restarts. After the restart PegaProx does not come up: ImportError: cannot import name 'bp' from 'pegaprox.api.settings'.
The rollback still looks for a single-file install. In rollback_pegaprox_update (pegaprox/api/settings.py):
current_dir = os.path.dirname(os.path.abspath(__file__))
current_backend = os.path.abspath(__file__) # pegaprox/api/settings.py itself
current_frontend = os.path.join(current_dir, 'index.html')
...
for f in os.listdir(backup_path):
if f.endswith('.py'):
backup_backend = os.path.join(backup_path, f)
break
...
shutil.copy2(backup_backend, current_backend)
The updater writes the backup as a tree: pegaprox/, web/ and static/ as directories, and pegaprox_multi_cluster.py, version.json and requirements.txt beside them. The only .py at the top of a backup is the launcher. So the launcher is copied over the module that holds the route. The frontend is not restored either: index.html is looked for at the top of the backup, and it is under web/.
Steps to Reproduce
- Start a container of
ghcr.io/pegaprox/pegaprox-testing:latestand create the first admin. - Make a backup the way the updater does (or run a real update): a directory
config/backups/pegaprox_1.4.1_<timestamp>/holding copies ofpegaprox/,web/,static/,pegaprox_multi_cluster.py,version.jsonandrequirements.txt. POST /api/pegaprox/update/rollbackwith{"backup": "pegaprox_1.4.1_<timestamp>"}.
What I got:
{"message":"Rolled back to pegaprox_1.4.1_20261110_120000. Server restarting...","restarting":true,"restored":["backend"],"success":true}
HTTP 200
Before the call, pegaprox/api/settings.py had 6791 lines (sha256 8ad3b81c...). After it, it had 273 lines and sha256 cb84579f..., the hash of pegaprox_multi_cluster.py. Then, at the restart:
File "/app/pegaprox/api/__init__.py", line 21, in register_blueprints
from pegaprox.api.settings import bp as settings_bp
ImportError: cannot import name 'bp' from 'pegaprox.api.settings' (/app/pegaprox/api/settings.py)
The container exited with code 1.
Expected behavior
The rollback puts back what the updater saved (pegaprox/, web/, static/ and the three files), or it refuses and says why. It never answers success after writing over a module of the running install.
Environment
- PegaProx Version: 1.4.1 (Testing, build of 10 Nov 2026, image
ghcr.io/pegaprox/pegaprox-testing:latest). The same lines are onmain, so the 1.4.1 release has it too. - Installation Method: Docker
- OS: the image's own (python:3.12-slim)
- Browser: not involved, the route was called with curl
- Behind Reverse Proxy? No
- UI? not involved
Logs
ImportError: cannot import name 'bp' from 'pegaprox.api.settings' (/app/pegaprox/api/settings.py)
Screenshots
None.
I can open a PR for this if the direction suits you. It would restore the saved directories and files from the backup tree, with a test that runs the route against a backup laid out by the updater. Do you want the rollback to go through update.sh instead? That script already restores web/ with its language files.
Checklist
- [x] I have searched existing issues to make sure this is not a duplicate
- [x] I am using the latest version of PegaProx
- [x] I've put enough in here that someone can start on it without asking me three questions first
- [x] I understand PegaProx is maintained by volunteers in their free time. Nobody is on call, and writing URGENT doesn't get anyone out of bed 🪄
Thanks for tracing this through. I can confirm it on Testing: the updater writes the backup as a tree (pegaprox/, web/, static/ plus the launcher, version.json and requirements.txt), while rollback_pegaprox_update still copies the first top-level .py over its own settings.py and looks for index.html at the top. Whether the rollback should restore the tree itself or go through update.sh is a call for the maintainers, so I've flagged this one for them together with your offer.
Jan-Philipp
Thanks Jan-Philipp. To help the maintainers decide, here is what the "restore the tree itself" option looks like on a branch: https://github.com/gputier/project-pegaprox/tree/fix/update-rollback-restores-the-tree (one commit on Testing 99df4577, pegaprox/api/settings.py and one test file).
What it does:
- every file under
pegaprox/,web/andstatic/of the backup goes back to the same path under the install directory, along withpegaprox_multi_cluster.py,version.jsonandrequirements.txt; - a backup without the launcher or without
pegaprox/api/settings.pyis refused with a 400 and nothing is written. Today such a backup answers "Rolled back" withrestored: []; - the answer keeps its two names,
backendandfrontend.
What it does not do, and where update.sh may be the better road:
- it copies back, it does not delete. A file that only the newer release has stays in place (there is a test that pins this), so the tree can be a mix of two releases;
- it does not reinstall the Python requirements of the older release;
- a copy that fails halfway leaves a partial restore. It is not atomic.
Tests, through the route, on a temporary install tree: 10 passed with the change, 10 failed on Testing (the launcher lands on settings.py, the page stays the new one).
I will not open a PR until you have chosen. If you go through update.sh, the tests may still be of use.
Thanks for writing that out. Restoring the tree the updater backed up, and refusing a backup without the launcher or settings.py, is the way we want it. We're putting that fix in on Testing along those lines together with today's other follow-ups.
Marcus
1.5.0 is out with this fixed, a rollback no longer overwrites settings.py with the launcher. Closing.
Nico