Skip to content

[16.0][FIX] auto_backup: allow scheduled backup when list_db is disabled - #3641

Open
klodr wants to merge 2 commits into
OCA:16.0from
klodr:16.0-fix-auto_backup-list_db
Open

klodr wants to merge 2 commits into
OCA:16.0from
klodr:16.0-fix-auto_backup-list_db

Conversation

@klodr

@klodr klodr commented Jun 6, 2026 •

Copy link
Copy Markdown

Problem

When list_db = False is set in the Odoo configuration, scheduled auto_backup
jobs fail with:

Database management functions blocked, admin disabled database listing

odoo.service.db.dump_db is decorated with @check_db_management_enabled, which
raises AccessDenied when list_db is False. The backup fails and leaves a
zero-byte dump file that cleanup() keeps and nothing flags.

Fix

  • _dump_db builds the dump in the module, with the same core tools and layout
    as dump_db (pg_dump, the filestore, osutil.zip_dir), taking the manifest
    from the undecorated dump_db_manifest. list_db is never touched: switching
    it on, even for the dump only, would reopen /web/database/list to anonymous
    callers on a threaded server.
  • pg_dump runs with check=True in both formats.
  • Local backups are written to a partial file of their own, renamed only once
    complete: a failed dump leaves no empty or truncated file behind.

Tests assert that pg_dump runs with list_db still off, that zip and dump
backups have content, and that a failed dump leaves no file; they fail without
the fix.

Port of #3639.

@legalsylvain
legalsylvain marked this pull request as draft June 6, 2026 08:25
@klodr
klodr marked this pull request as ready for review August 6, 2026 20:57
@klodr

klodr commented Sep 12, 2026

Copy link
Copy Markdown
Author

@OCA/server-tools-maintainers gentle ping — all 9 checks are green and the branch is conflict-free. This has been open since June with no review. It is the 16.0 member of a five-branch set (#3639 18.0, #3640 17.0, this one 16.0, #3642 15.0, #3643 14.0); reviewing one should make the others straightforward.

@klodr

klodr commented Nov 24, 2026

Copy link
Copy Markdown
Author

Reworked like #3640, following its review: the dump no longer switches list_db on, and a failed dump leaves no file behind. Tested on this version.

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]>
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
klodr force-pushed the 16.0-fix-auto_backup-list_db branch from bf6051e to 4242136 Compare November 24, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants