#7684·gogs

gogs restore in Docker failure - GOGS_CUSTOM /data/gogs is moved

Author: vallonCreated Mar 13, 2024Updated Sep 4, 2026
Labels💊 bug

Gogs version

v0.13.0

Git version

  • Server: n/a
  • Client: n/a

Operating system

Docker v0.13.0

Database

sqlite3

Describe the bug

I've had some trouble migrating from a non-Docker installation of gogs to a dockerized version. I dumped the old gogs version 0.11.91.0811, and then tried to load into the docker container with:

source /app/gogs/docker/s6/gogs/setup # creates log symlinks
gosu $USER mkdir /data/tmp # same vol as /data so rename works
gosu $USER /app/gogs/gogs restore --verbose --from /restore/gogs-backup.zip --config /restore/app.ini --tempdir /data/tmp

But, after this, I end up with:

/data/git/...
/data/gogs/ (empty)
/data/gogs.bak/data/gogs.db
/data/gogs.bak/conf
/data/gogs.bak/log/...

It appears to be:

  1. https://github.com/gogs/gogs/blob/fa84482d98eed6488f448aad25d322b403c804e5/Dockerfile#L28 sets GOGS_CUSTOM=/data/gogs
  2. https://github.com/gogs/gogs/blob/fa84482d98eed6488f448aad25d322b403c804e5/internal/conf/computed.go#L80 computes conf.CustomDir() to be getenv("GOGS_CUSTOM") with fallback to WorkDir()/"custom".
  3. conf.CustomDir() is "/data/gogs"
  4. https://github.com/gogs/gogs/blob/fa84482d98eed6488f448aad25d322b403c804e5/internal/cmd/restore.go#L124 tries to restore "$archivedir/custom" directory by renaming the old $GOGS_CUSTOM to $GOGS_CUSTOM.bak, then moving the archive/custom dir to $GOGS_CUSTOM.

That has renamed /data/gogs/data/gogs.db to /data/gogs.bak/data/gogs.db.

To reproduce

It seems what is required:

  • gogs restore in Docker (where GOGS_CUSTOM=/data/gogs)
  • backup archive contains a "custom" dir (v0.11.91.0811 backup fails if there is no custom dir)
  • database.type = sqlite3; database.path = data/gogs.db

Expected behavior

database should be in correct place after restore.

Since I am starting with a fresh /data directory, my workaround is to mv /data/gogs.bak/* /data/gogs/.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct