Allow gitea dump with readonly sqlite database #6901

Closed
opened 2025-11-02 07:10:37 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @nickbabcock on GitHub (Feb 19, 2021).

  • Gitea version (or commit ref): 1.13.2
  • Database:
    • SQLite

Description

Given that the following works:

docker run --rm -ti -w /tmp --user git -v "${PWD}:/tmp" --volume gitea_gitea:/data gitea/gitea:1 gitea dump

Mounting the volume as readonly will not work:

docker run --rm -ti -w /tmp --user git -v "${PWD}:/tmp" --volume gitea_gitea:/data:ro gitea/gitea:1 gitea dump

The gitea dump will error with:

Failed to dump database: attempt to write a readonly database

As it appears the dump command tries to write to the database

It seems preferential to allows users to backup data without needing write access. Though I do not know what the solution would be that wouldn't regress on https://github.com/go-gitea/gitea/issues/14069 . Looking at the code and issues, it sounds like this problem will be resolved with 1.14 so feel free to close this issue if backporting a fix is not worth it.

Originally created by @nickbabcock on GitHub (Feb 19, 2021). - Gitea version (or commit ref): 1.13.2 - Database: - [x] SQLite ## Description Given that the following works: ```bash docker run --rm -ti -w /tmp --user git -v "${PWD}:/tmp" --volume gitea_gitea:/data gitea/gitea:1 gitea dump ``` Mounting the volume as readonly will not work: ```bash docker run --rm -ti -w /tmp --user git -v "${PWD}:/tmp" --volume gitea_gitea:/data:ro gitea/gitea:1 gitea dump ``` The `gitea dump` will error with: ``` Failed to dump database: attempt to write a readonly database ``` [As it appears the dump command tries to write to the database](https://github.com/go-gitea/gitea/blob/014313134f72ebb2ca57eb2e5cd42726231f8fff/models/models.go#L320) It seems preferential to allows users to backup data without needing write access. Though I do not know what the solution would be that wouldn't regress on https://github.com/go-gitea/gitea/issues/14069 . Looking at the code and issues, it sounds like this problem will be resolved with 1.14 so feel free to close this issue if backporting a fix is not worth it.
GiteaMirror added the type/enhancement label 2025-11-02 07:10:37 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Apr 16, 2022):

If you do not lock the database, you get an inconsistent backup.

@wxiaoguang commented on GitHub (Apr 16, 2022): If you do not lock the database, you get an inconsistent backup.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6901