Repository navigation
Conversation
odoo.service.db.dump_db is guarded by check_db_management_enabled, which raises AccessDenied ("Database management functions blocked, admin disabled database listing") when list_db = False is set in the Odoo configuration. Scheduled backups then failed silently, leaving zero-byte files.
list_db only hides database management from the web interface; a scheduled backup is a trusted server-side operation. Re-enable the flag for the duration of the dump through a context manager that always restores its original value, even on error.
Signed-off-by: klodr <[email protected]>
This was referenced Jun 6, 2026
legalsylvain
marked this pull request as draft
June 6, 2026 08:26
klodr
marked this pull request as ready for review
August 6, 2026 20:57
Author
|
Reworked like #3640, following its review: the dump no longer switches |
Switching list_db on for the duration of the dump reopened the database manager routes, /web/database/list included (auth='none'), to every request served meanwhile by the same process: on a threaded server, anonymous callers got the database list for the whole backup. Build the dump in the module instead, with the same core tools and the same layout as odoo.service.db.dump_db (pg_dump, the filestore, osutil.zip_dir), taking the manifest from the undecorated dump_db_manifest. list_db is never touched. Calling dump_db.__wrapped__ alone is not enough for zip backups: it calls dump_db_manifest, which is guarded too. pg_dump now runs with check=True in both formats, and local backups are written to a partial file of their own, renamed only once complete: a failed dump no longer leaves an empty or truncated file that cleanup() keeps. The tests assert that list_db stays off while pg_dump runs, that zip and dump backups have content, and that a failed dump leaves no file behind; they fail without this change. The version bump is left to ocabot. Signed-off-by: klodr <[email protected]>
klodr
force-pushed
the
18.0-fix-auto_backup-list_db
branch
from
November 24, 2026 05:08
0dd98d0 to
268627c
Compare
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.
Problem
When
list_db = Falseis set in the Odoo configuration, scheduledauto_backupjobs fail with:
odoo.service.db.dump_dbis decorated with@check_db_management_enabled, whichraises
AccessDeniedwhenlist_dbis False. The backup fails and leaves azero-byte dump file that
cleanup()keeps and nothing flags.Fix
_dump_dbbuilds the dump in the module, with the same core tools and layoutas
dump_db(pg_dump, the filestore,osutil.zip_dir), taking the manifestfrom the undecorated
dump_db_manifest.list_dbis never touched: switchingit on, even for the dump only, would reopen
/web/database/listto anonymouscallers on a threaded server.
pg_dumpruns withcheck=Truein both formats.complete: a failed dump leaves no empty or truncated file behind.
Tests assert that
pg_dumpruns withlist_dbstill off, that zip and dumpbackups have content, and that a failed dump leaves no file; they fail without
the fix.