Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression when creating backup: backup file equal to disk size is created #13618

Closed
1 of 6 tasks
pat-s opened this issue Nov 18, 2020 · 7 comments · Fixed by #14606
Closed
1 of 6 tasks

Regression when creating backup: backup file equal to disk size is created #13618

pat-s opened this issue Nov 18, 2020 · 7 comments · Fixed by #14606
Labels

Comments

@pat-s
Copy link
Member

pat-s commented Nov 18, 2020

  • Gitea version: 1.13-rc2
  • Git version: 2.26.2
  • Operating system: ubuntu 20.04 (Gitea via docker)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:

Description

When dumping a backup of a gitea docker install via

docker exec -u git gitea bash -c 'gitea dump -w /tmp -c /data/gitea/conf/app.ini -f /data/gitea/conf/backup_gitea_$(date +\%d-\%m-\%Y).zip'

the output file that gets created fills up the whole disk space within ~10 seconds.

However, when executing the commands from above in parts, the backups is created just fine and finishes in < 1 sec:

docker exec -it gitea bash
su - git
gitea dump -w /tmp -c /data/gitea/conf/app.ini -f /data/gitea/conf/backup_gitea_assets_$(date +\%d-\%m-\%Y).zip

I also tried this on 1.14.0+dev-233-g0615b668d.

docker version
Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 17:02:52 2020
 OS/Arch:           linux/amd64
 Experimental:      false
@6543 6543 added the type/bug label Nov 18, 2020
@pat-s
Copy link
Member Author

pat-s commented Nov 19, 2020

I digged a bit deeper and turning on verbosity I found the following

bad case (docker exec)

docker exec --user git gitea bash -c 'gitea dump -V -w /tmp -c /data/gitea/conf/app.ini -f /data/gitea/conf/backup_gitea_assets_$(date +\%d-\%m-\%Y).zip'

2020/11/19 15:16:41 cmd/dump.go:278:runDump() [I] Dumping database...
2020/11/19 15:16:41 cmd/dump.go:32:addFile() [I] Adding file gitea-db.sql
2020/11/19 15:16:41 cmd/dump.go:290:runDump() [I] Adding custom configuration file from /data/gitea/conf/app.ini
2020/11/19 15:16:41 cmd/dump.go:32:addFile() [I] Adding file app.ini
2020/11/19 15:16:41 cmd/dump.go:55:addRecursive() [I] Adding dir  custom
2020/11/19 15:16:41 cmd/dump.go:55:addRecursive() [I] Adding dir  custom/conf
2020/11/19 15:16:41 cmd/dump.go:32:addFile() [I] Adding file custom/conf/backup_gitea_assets_19-11-2020.zip
Failed to include custom: custom/conf/backup_gitea_assets_19-11-2020.zip: copying contents: write /data/gitea/conf/backup_gitea_assets_19-11-2020.zip: no space left on device

good case (interactive in the container)

gitea dump -V -w /tmp -c /data/gitea/conf/app.ini -f /data/gitea/conf/backup_gitea_assets_$(date +\%d-\%m-\%Y).zip

2020/11/19 15:18:40 cmd/dump.go:278:runDump() [I] Dumping database...
2020/11/19 15:18:41 cmd/dump.go:32:addFile() [I] Adding file gitea-db.sql
2020/11/19 15:18:41 cmd/dump.go:290:runDump() [I] Adding custom configuration file from /data/gitea/conf/app.ini
2020/11/19 15:18:41 cmd/dump.go:32:addFile() [I] Adding file app.ini
2020/11/19 15:18:41 cmd/dump.go:306:runDump() [I] Custom dir /usr/local/bin/custom doesn't exist, skipped
2020/11/19 15:18:41 cmd/dump.go:55:addRecursive() [I] Adding dir  log
2020/11/19 15:18:41 cmd/dump.go:370:runDump() [I] Finish dumping in file /data/gitea/conf/backup_gitea_assets_19-11-2020.zip

Note the difference after Adding file app.ini.

Unfortunately setting -C somevalue did not work: docker exec --user git gitea bash -c 'gitea dump -V -w /tmp -c /data/gitea/conf/app.ini -C /foo -f /data/gitea/conf/backup_gitea_assets_$(date +\%d-\%m-\%Y).zip'.

2020/11/19 15:24:09 cmd/dump.go:278:runDump() [I] Dumping database...
2020/11/19 15:24:09 cmd/dump.go:32:addFile() [I] Adding file gitea-db.sql
2020/11/19 15:24:09 cmd/dump.go:290:runDump() [I] Adding custom configuration file from /data/gitea/conf/app.ini
2020/11/19 15:24:09 cmd/dump.go:32:addFile() [I] Adding file app.ini
2020/11/19 15:24:09 cmd/dump.go:306:runDump() [I] Custom dir /foo doesn't exist, skipped
2020/11/19 15:24:09 cmd/dump.go:310:runDump() [I] Packing data directory...data
2020/11/19 15:24:09 cmd/dump.go:32:addFile() [I] Adding file data/gitea/conf/backup_gitea_assets_19-11-2020.zip
Failed to include data directory: data/gitea/conf/backup_gitea_assets_19-11-2020.zip: copying contents: write /data/gitea/conf/backup_gitea_assets_19-11-2020.zip: no space left on device
2020/11/19 15:24:13 cmd/dump.go:171:fatal() [F] Failed to include data directory: data/gitea/conf/backup_gitea_assets_19-11-2020.zip: copying contents: write /data/gitea/conf/backup_gitea_assets_19-11-2020.zip: no space left on device

@pat-s
Copy link
Member Author

pat-s commented Nov 23, 2020

Is there a better way of doing backups via docker?

This blocks us since we are unable to do automatic backups.

I also added docker version info to the OP.

@6543
Copy link
Member

6543 commented Nov 23, 2020

Is there a better way of doing backups

@pat-s you just have to save: the database, config-file & data folder. so you could simply create your own backup solution based on your enviroment ... e.g. docker

@pat-s
Copy link
Member Author

pat-s commented Nov 23, 2020

right! I was loosing focus.

We are already backing up the DB and I could simply zip the other assets via the mounted volume 🤦

DBNAME=gitea; zip -q -r backup_$(echo $DBNAME)_$(date +\%d-\%m-\%Y)_assets.zip /home/ubuntu/gitea/gitea
s3cmd put /home/ubuntu/backup_$(echo $DBNAME)_$(date +\%d-\%m-\%Y)_assets.zip s3://s3-name/backup_$(echo $DBNAME)_$(date +\%d-\%m-\%Y)_assets.zip
rm /home/ubuntu/backup_gitea_$(date +\%d-\%m-\%Y)_assets.zip

@Alsiri0n
Copy link

Same problem on 1.13.1 version.

@Alsiri0n
Copy link

Alsiri0n commented Feb 2, 2021

Same problem on 1.13.2 version.

zeripath added a commit to zeripath/gitea that referenced this issue Feb 7, 2021
Always prevent the current file from being added to the dump.

Fix go-gitea#13618

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor

zeripath commented Feb 7, 2021

OK this is a not a regression - just a change in behaviour. It was never expected that you would store your backups in the custom directory and within the path of things added to the dump.

I've provided a PR to prevent adding the current dump file to the dump and to provide an option to prevent adding the custom dir.

lunny pushed a commit that referenced this issue Feb 8, 2021
* Exclude the current dump file from the dump

Always prevent the current file from being added to the dump.

Fix #13618

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Add skip custom directory option

Signed-off-by: Andrew Thornton <art27@cantab.net>

* placate lint

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: 6543 <6543@obermui.de>
@go-gitea go-gitea locked and limited conversation to collaborators Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants