Dump doesn't include custom folder #6559

Closed
opened 2025-11-02 06:59:26 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @DuckDuckWhale on GitHub (Dec 21, 2020).

  • Gitea version (or commit ref): 1.13.0
  • Git version: 2.25.1
  • Operating system: Ubuntu Server 20.04 LTS
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • N/A
  • Log gist: will post if requested

Description

When dumping it says cmd/dump.go:306:runDump() [I] Custom dir /usr/local/bin/custom doesn't exist, skipped although working directory is /var/lib/gitea (set via both systemd and env var) and custom directory is /var/lib/gitea/custom as shown in the configuration admin page.

Originally created by @DuckDuckWhale on GitHub (Dec 21, 2020). - Gitea version (or commit ref): 1.13.0 - Git version: 2.25.1 - Operating system: Ubuntu Server 20.04 LTS - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] N/A - Log gist: will post if requested ## Description When dumping it says `cmd/dump.go:306:runDump() [I] Custom dir /usr/local/bin/custom doesn't exist, skipped` although working directory is `/var/lib/gitea` (set via both systemd and env var) and custom directory is `/var/lib/gitea/custom` as shown in the configuration admin page.
GiteaMirror added the type/questiontype/docs labels 2025-11-02 06:59:26 -06:00
Author
Owner

@techknowlogick commented on GitHub (Dec 21, 2020):

Can you provide the exact command you are running for dump (along with args), as well as can you confirm which env vars that are in your terminal that gitea specific when running dump?

@techknowlogick commented on GitHub (Dec 21, 2020): Can you provide the exact command you are running for dump (along with args), as well as can you confirm which env vars that are in your terminal that gitea specific when running dump?
Author
Owner

@DuckDuckWhale commented on GitHub (Dec 21, 2020):

The command that I ran is gitea dump -c /etc/gitea/app.ini -w /var/lib/gitea/ -f ~/gitea-dump.zip. I meant the env var for the running gitea service (which on second thought might not affect the dump command). I have no gitea specific env var (excluding HOME, USER, etc.) when running dump in terminal.

@DuckDuckWhale commented on GitHub (Dec 21, 2020): The command that I ran is `gitea dump -c /etc/gitea/app.ini -w /var/lib/gitea/ -f ~/gitea-dump.zip`. I meant the env var for the running gitea service (which on second thought might not affect the dump command). I have no gitea specific env var (excluding `HOME`, `USER`, etc.) when running dump in terminal.
Author
Owner

@DuckDuckWhale commented on GitHub (Dec 29, 2020):

Still the case after upgrading to 1.13.1.

@DuckDuckWhale commented on GitHub (Dec 29, 2020): Still the case after upgrading to 1.13.1.
Author
Owner

@rnveach commented on GitHub (Jun 23, 2021):

I have this issue on 1.14.2 .
LUbuntu 18.04 installed gitea's data into /var/lib/gitea/ but when I run the dump command with /etc/gitea/app.ini I get similar errors.

rnveach@ubuntu:/tmp$ sudo -u git bash
git@ubuntu:/tmp$ cd /tmp
git@ubuntu:/tmp$ gitea dump -c /etc/gitea/app.ini
2021/06/22 22:15:03 ...dules/setting/git.go:101:newGit() [I] Git Version: 2.17.1
2021/06/22 22:15:03 ...dules/setting/log.go:287:newLogService() [I] Gitea v1.14.2 built with GNU Make 4.1, go1.16.4 : bindata, sqlite, sqlite_unlock_notify
2021/06/22 22:15:03 ...dules/setting/log.go:333:newLogService() [I] Gitea Log Mode: Console(Console:info)
2021/06/22 22:15:03 ...dules/setting/log.go:250:generateNamedLogger() [I] Router Log: Console(console:info)
2021/06/22 22:15:03 ...les/setting/cache.go:73:newCacheService() [I] Cache Service Enabled
2021/06/22 22:15:03 ...les/setting/cache.go:88:newCacheService() [I] Last Commit Cache Service Enabled
2021/06/22 22:15:03 ...s/setting/session.go:77:newSessionService() [I] Session Service Enabled
2021/06/22 22:15:03 ...s/storage/storage.go:158:initAttachments() [I] Initialising Attachment storage with type:
2021/06/22 22:15:03 ...les/storage/local.go:47:NewLocalStorage() [I] Creating new Local Storage at /usr/local/bin/data/attachments
2021/06/22 22:15:03 main.go:117:main() [F] Failed to run app with [gitea dump -c /etc/gitea/app.ini]: mkdir /usr/local/bin/data: permission denied
git@ubuntu:/tmp$

The gitea program is located at /usr/local/bin so it seems like the dump command is defaulting to the data to be located in it's own directory.

No issues running gitea besides trying to dump for a backup. No environment variables defined for gitea.

@rnveach commented on GitHub (Jun 23, 2021): I have this issue on 1.14.2 . LUbuntu 18.04 installed gitea's data into `/var/lib/gitea/` but when I run the dump command with `/etc/gitea/app.ini` I get similar errors. ```` rnveach@ubuntu:/tmp$ sudo -u git bash git@ubuntu:/tmp$ cd /tmp git@ubuntu:/tmp$ gitea dump -c /etc/gitea/app.ini 2021/06/22 22:15:03 ...dules/setting/git.go:101:newGit() [I] Git Version: 2.17.1 2021/06/22 22:15:03 ...dules/setting/log.go:287:newLogService() [I] Gitea v1.14.2 built with GNU Make 4.1, go1.16.4 : bindata, sqlite, sqlite_unlock_notify 2021/06/22 22:15:03 ...dules/setting/log.go:333:newLogService() [I] Gitea Log Mode: Console(Console:info) 2021/06/22 22:15:03 ...dules/setting/log.go:250:generateNamedLogger() [I] Router Log: Console(console:info) 2021/06/22 22:15:03 ...les/setting/cache.go:73:newCacheService() [I] Cache Service Enabled 2021/06/22 22:15:03 ...les/setting/cache.go:88:newCacheService() [I] Last Commit Cache Service Enabled 2021/06/22 22:15:03 ...s/setting/session.go:77:newSessionService() [I] Session Service Enabled 2021/06/22 22:15:03 ...s/storage/storage.go:158:initAttachments() [I] Initialising Attachment storage with type: 2021/06/22 22:15:03 ...les/storage/local.go:47:NewLocalStorage() [I] Creating new Local Storage at /usr/local/bin/data/attachments 2021/06/22 22:15:03 main.go:117:main() [F] Failed to run app with [gitea dump -c /etc/gitea/app.ini]: mkdir /usr/local/bin/data: permission denied git@ubuntu:/tmp$ ```` The gitea program is located at `/usr/local/bin` so it seems like the dump command is defaulting to the data to be located in it's own directory. No issues running gitea besides trying to dump for a backup. No environment variables defined for gitea.
Author
Owner

@rnveach commented on GitHub (Jun 23, 2021):

Relooking at https://docs.gitea.io/en-us/linux-service/ for when I set up the service to run my installation, the service was created from https://github.com/go-gitea/gitea/blob/main/contrib/systemd/gitea.service .

https://github.com/go-gitea/gitea/blob/main/contrib/systemd/gitea.service#L62 sets up the service to have the working directory as /var/lib/gitea/. So this is where the custom directory is coming from in my installation for where data is stored.

So there seems to be a disconnect in the dump that it isn't set to use this directory by default or documentation that this is required.
Is it possible to give it an override path to circumvent this for now?

@rnveach commented on GitHub (Jun 23, 2021): Relooking at https://docs.gitea.io/en-us/linux-service/ for when I set up the service to run my installation, the service was created from https://github.com/go-gitea/gitea/blob/main/contrib/systemd/gitea.service . https://github.com/go-gitea/gitea/blob/main/contrib/systemd/gitea.service#L62 sets up the service to have the working directory as `/var/lib/gitea/`. So this is where the custom directory is coming from in my installation for where data is stored. So there seems to be a disconnect in the dump that it isn't set to use this directory by default or documentation that this is required. Is it possible to give it an override path to circumvent this for now?
Author
Owner

@zeripath commented on GitHub (Jun 23, 2021):

Yes. Read the documentation or the output from --help:

--custom-path path, -C path: Location of the Gitea custom folder. Optional. (default: AppWorkPath/custom or $GITEA_CUSTOM).

https://docs.gitea.io/en-us/command-line/#global-options

Read the documentation about environment variables:

GITEA_CUSTOM: Gitea uses GITEA_WORK_DIR/custom folder by default. Use this variable to change custom directory.

https://docs.gitea.io/en-us/environment-variables/#gitea-files

If you look at the first lines of stdoutput from gitea it tells you where that execution thinks certain things are - including custom path.

If you read the service file it tells you that it's setting environment variables to change the places gitea is looking for things.

This is a repeated common issue. By default gitea is not built in a FHS compliant fashion. There are several options: build it FHS compliant by setting ldflags flags as described in the documentation, use a shadowing script or just deal with it by setting the appropriate environment variables/cmd flags. You have chosen the third approach and therefore you need to use the flags/environment variables.

I've long argued we should be providing a FHS compliant build.

@zeripath commented on GitHub (Jun 23, 2021): Yes. Read the documentation or the output from --help: --custom-path path, -C path: Location of the Gitea custom folder. Optional. (default: AppWorkPath/custom or $GITEA_CUSTOM). https://docs.gitea.io/en-us/command-line/#global-options Read the documentation about environment variables: GITEA_CUSTOM: Gitea uses GITEA_WORK_DIR/custom folder by default. Use this variable to change custom directory. https://docs.gitea.io/en-us/environment-variables/#gitea-files If you look at the first lines of stdoutput from gitea it tells you where that execution thinks certain things are - including custom path. If you read the service file it tells you that it's setting environment variables to change the places gitea is looking for things. This is a repeated common issue. By default gitea is not built in a FHS compliant fashion. There are several options: build it FHS compliant by setting ldflags flags as described in the documentation, use a shadowing script or just deal with it by setting the appropriate environment variables/cmd flags. You have chosen the third approach and therefore you need to use the flags/environment variables. I've long argued we should be providing a FHS compliant build.
Author
Owner

@rnveach commented on GitHub (Jun 23, 2021):

Thanks, I didn't try the help command I am sorry to say.

-C didn't resolve my issue but -w with the following command did: sudo -u git gitea dump -c /etc/gitea/app.ini -w /var/lib/gitea

I feel the documentation at https://docs.gitea.io/en-us/backup-and-restore/ and https://docs.gitea.io/en-us/command-line/#dump should mention this option in some form since the default service uses it.

@rnveach commented on GitHub (Jun 23, 2021): Thanks, I didn't try the help command I am sorry to say. `-C` didn't resolve my issue but `-w` with the following command did: `sudo -u git gitea dump -c /etc/gitea/app.ini -w /var/lib/gitea` I feel the documentation at https://docs.gitea.io/en-us/backup-and-restore/ and https://docs.gitea.io/en-us/command-line/#dump should mention this option in some form since the default service uses it.
Author
Owner

@techknowlogick commented on GitHub (Jun 25, 2021):

@rnveach If you would be open to creating a PR for our docs (found under the docs folder of this repo) with this additional information we'd be happy to accept it :)

@techknowlogick commented on GitHub (Jun 25, 2021): @rnveach If you would be open to creating a PR for our docs (found under the docs folder of this repo) with this additional information we'd be happy to accept it :)
Author
Owner

@DuckDuckWhale commented on GitHub (Jun 25, 2021):

Just tested on 1.14.2 and the -C option is able to let Gitea know the correct path of the custom directory (and with -w but without -C still doesn't work). When I read the docs it says that the custom path defaults to AppWorkPath/custom or $GITEA_CUSTOM, but using the -w flag to set AppWorkPath somehow doesn't change the custom path with it; it still looks in /usr/local/bin/custom. Is this a bug or is the documentation not clear?

@DuckDuckWhale commented on GitHub (Jun 25, 2021): Just tested on 1.14.2 and the `-C` option is able to let Gitea know the correct path of the custom directory (and with `-w` but without `-C` still doesn't work). When I read the docs it says that the custom path defaults to `AppWorkPath/custom` or `$GITEA_CUSTOM`, but using the `-w` flag to set `AppWorkPath` somehow doesn't change the custom path with it; it still looks in `/usr/local/bin/custom`. Is this a bug or is the documentation not clear?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6559