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

Docker: Backup command does not ignore temporary data directory data/tmp #6785

Closed
1 task done
jjakob opened this issue Feb 25, 2022 · 3 comments · Fixed by #7343
Closed
1 task done

Docker: Backup command does not ignore temporary data directory data/tmp #6785

jjakob opened this issue Feb 25, 2022 · 3 comments · Fixed by #7343
Assignees
Labels
💊 bug Something isn't working ⚓️ docker Categorizes as related to Docker
Milestone

Comments

@jjakob
Copy link

jjakob commented Feb 25, 2022

Gogs version

0.12.4

Git version

  • Server: 2.32.0
  • Client: 2.17.1

Operating system

official docker image gogs/gogs:0.12 sha256:f903b2d8de7e49a3619929a663229ec26d6d9ab67be63aab1552e89f959e2acd in Docker Community 20.10.12 on Ubuntu 18.04 LTS

Database

PostgreSQL 9.5.18

Describe the bug

Executing this command to run a backup to a mounted volume:

docker exec gogs_gogs_1 /bin/sh -c "umask 0027; USER=git ./gogs backup --target=/backup/"

gives this error:

# docker exec gogs_gogs_1 /bin/sh -c "umask 0027; USER=git ./gogs backup -
-target=/backup/"
2022/02/25 17:12:38 [ INFO] Backup root directory: /tmp/gogs-backup-2463318712
2022/02/25 17:12:38 [ INFO] Packing backup files to: /backup/gogs-backup-20220225171237.zip
2022/02/25 17:12:43 [FATAL] [...s.io/gogs/internal/cmd/backup.go:105 runBackup()] Failed to include 'custom
': open /data/gogs/data/tmp/local-repo/42/docker-compose.common.yml: no such file or directory

It used to work with no problem just a few days ago (scheduled daily) also on 0.12.4, the upgrade from 0.12.3 was done as soon as 0.12.4 came out. I think it was caused by some changes in the repositories hosted in gogs.

2022/02/19 23:46:42 [ INFO] Backup root directory: /tmp/gogs-backup-3440401522
2022/02/19 23:46:42 [ INFO] Packing backup files to: /backup/gogs-backup-20220219234642.zip
2022/02/19 23:46:50 [ INFO] Dumping repositories in "/data/git/gogs-repositories"
2022/02/19 23:49:20 [ INFO] Repositories dumped to: /tmp/gogs-backup-3440401522/repositories.zip
2022/02/19 23:52:15 [ INFO] Backup succeed! Archive is located at: /backup/gogs-backup-20220219234642.zip

To reproduce

Described above

Expected behavior

successful backup

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jjakob jjakob added the 💊 bug Something isn't working label Feb 25, 2022
@jjakob
Copy link
Author

jjakob commented Feb 25, 2022

Finding that path in the data volume, the file exists, but is a symlink, pointing to a nonexistent file (because it's a symlink commited into a repository, its target is not valid inside the gogs container, neither should it be valid)

# ls -la /var/lib/docker/volumes/gogs-data/_data/gogs/data/tmp/local-repo/42/docker-compose.common.yml
lrwxrwxrwx 1 localadmin localadmin 56 Feb 21 14:17 /var/lib/docker/volumes/gogs-data/_data/gogs/data/tmp/local-repo/42/docker-compose.common.yml -> devops_scripts/docker/drupal-8/docker-compose.common.yml

Probably the command gogs is running to backup this location isn't backing up symlinks as-is, but is dereferencing them, which it probably shouldn't do?

@unknwon
Copy link
Member

unknwon commented Mar 9, 2022

Probably the command gogs is running to backup this location isn't backing up symlinks as-is, but is dereferencing them, which it probably shouldn't do?

Good find! I think the backup command shouldn't include data/tmp at all since this is directory is for a temporary data and gets cleaned up regularly.

As a workaround, you may delete your /var/lib/docker/volumes/gogs-data/_data/gogs/data/tmp before running the backup command.

@unknwon unknwon changed the title Backup stopped working: [FATAL] [...s.io/gogs/internal/cmd/backup.go:105 runBackup()] Failed to include 'custom ': open /data/gogs/data/tmp/local-repo/42/docker-compose.common.yml: no such file or directory Backup command is including temporary data directory data/tmp Mar 9, 2022
@unknwon unknwon changed the title Backup command is including temporary data directory data/tmp Backup command does not ignore temporary data directory data/tmp Mar 9, 2022
@unknwon unknwon added the 🐣 pull request welcome Welcome to contribute for this! label Mar 9, 2022
@unknwon unknwon added this to the 0.13.0 milestone Mar 25, 2022
@unknwon unknwon self-assigned this Feb 11, 2023
@unknwon unknwon removed the 🐣 pull request welcome Welcome to contribute for this! label Feb 11, 2023
@unknwon unknwon changed the title Backup command does not ignore temporary data directory data/tmp Docker: backup command does not ignore temporary data directory data/tmp Feb 11, 2023
@unknwon unknwon changed the title Docker: backup command does not ignore temporary data directory data/tmp Docker: Backup command does not ignore temporary data directory data/tmp Feb 11, 2023
@unknwon unknwon added the ⚓️ docker Categorizes as related to Docker label Feb 11, 2023
@unknwon
Copy link
Member

unknwon commented Feb 11, 2023

Good find! I think the backup command shouldn't include data/tmp at all since this is directory is for a temporary data and gets cleaned up regularly.

For reference, turns out the root issue was the in the Docker setup, the "data" directory is a sub-directory of the custom directory 🤦‍♂️

CleanShot 2023-02-12 at 00 14 21@2x

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💊 bug Something isn't working ⚓️ docker Categorizes as related to Docker
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants