cooperspencer / gickup

https://cooperspencer.github.io/gickup-documentation/
Apache License 2.0
962 stars 34 forks source link

Gitea Backup Destination fails to back up wiki repositories #126

Closed TMUniversal closed 1 year ago

TMUniversal commented 1 year ago

Hey there!

I'm trying to back up from GitHub to Gitea, and I am experiencing some issues:

Gickup fatally fails to back up wikis.

Logs:

2022-12-09 13:10:20 INF mirroring UglifyJS to https://[REDACTED] stage=gitea url=https://[REDACTED]
2022-12-09 13:10:26 INF mirrored UglifyJS to https://[REDACTED] stage=gitea url=https://[REDACTED]
2022-12-09 13:10:26 INF starting backup for https://github.com/mishoo/UglifyJS.wiki.git stage=backup
2022-12-09 13:10:26 INF mirroring UglifyJS.wiki to https://[REDACTED] stage=gitea url=https://[REDACTED]
2022-12-09 13:10:26 FTL 422 Unprocessable Entity: {"message":"The pattern '*.wiki' is not allowed in a username.","url":"https://[REDACTED]/api/swagger"}
 stage=gitea url=https://[REDACTED]

I just switched to Gitea from local backup, where this was working well.

cooperspencer commented 1 year ago

Hi, what does your config look like?

TMUniversal commented 1 year ago

Hi, what does your config look like?

source:
  github:
    - token_file: /run/secrets/token_github
      wiki: true
      starred: true

destination:
#  local:
#    - path: /gickup/data
#      structured: true # checks repos out like hostersite/user|organization/repo
  gitea:
    - token: [REDACTED]
      user: tmuniversal
      url: https://[REDACTED]
      createorg: true # creates organization if it doesn't exist already

cron: 0 * * * * # optional
# https://crontab.guru/

log:
  timeformat: 2006-01-02 15:04:05
  file-logging:
    dir: log
    file: gickup.log
    maxage: 7

metrics:
  prometheus:
    endpoint: /metrics
    listen_addr: ":6178"
  heartbeat:
    urls:
      - [REDACTED]
cooperspencer commented 1 year ago

is there a user called tmuniversal on your gitea instance? Because the organization will only be created if either user/org is called whatever it says in the config, in your case tmuniversal.

Regarding the wiki backup, I never really used that, but it seems there is a bug about that. I will have a look at that

TMUniversal commented 1 year ago

is there a user called tmuniversal on your gitea instance? Because the organization will only be created if either user/org is called whatever it says in the config, in your case tmuniversal.

Regarding the wiki backup, I never really used that, but it seems there is a bug about that. I will have a look at that

There is a user called tmuniversal on the gitea instance, with permission to create organizations.

gickup creates all repositories in this user's name, though, which is not what I was hoping for. I'd like it to create the organizations the repositories originate from.

cooperspencer commented 1 year ago

it is not implemented that way. How should it look like? create a organization for the original owner of the repo or of the website, like github.com?

TMUniversal commented 1 year ago

it is not implemented that way. How should it look like? create a organization for the original owner of the repo or of the website, like github.com?

That does make it more difficult, I hadn't thought about creating an org for the website.

I was thinking a (GitHub) repo github.com/AnOrg/SomeRepo should become gitea.example.com/AnOrg/SomeRepo

cooperspencer commented 1 year ago

no biggie. I will implement that :+1:

TMUniversal commented 1 year ago

Are you also able to allow configuring the visibility of organizations/repositories?

cooperspencer commented 1 year ago

I am done with the org creation. How would you like to configure the visibility? Would it be fine if I add a visibility parameter in the destination config?

visibility:
  organizations: public
  repositories: private
TMUniversal commented 1 year ago

I am done with the org creation. How would you like to configure the visibility? Would it be fine if I add a visibility parameter in the destination config?

visibility:
  organizations: public
  repositories: private

oh wow, you're quick.

config options look very intuitive, i like it!

cooperspencer commented 1 year ago

I guess I am done. I will run a few tests and then upload it.

cooperspencer commented 1 year ago

The changes are now in the main branch. Can you compile it and test if it works for you as expected?

TMUniversal commented 1 year ago

So visibility seems to working in my limited testing, but organizations are not being created. To avoid having all repos in my own account, I created an org called backup and set the destinations user to backup, this is causing all repos to be created in the org backup, rather than their own org...

image

cooperspencer commented 1 year ago

if you don't use the user parameter in gitea of your destination, it should create the orgs

TMUniversal commented 1 year ago

That has done it! Thank you for implementing this!

TMUniversal commented 1 year ago

Backup destination config for reference

destination:
  gitea:
    - token: your-token
      #user: do not include user if you want orgs to be created
      url: https://gitea.example.com
      createorg: true # creates organization if it doesn't exist already
      visibility:
        repositories: private # private, public, default: private
        organizations: private # private, limited, public, default: private

It should be possible (although I will not be testing this now) to create repositories with visibility internal, by setting repo visibility to public, but org visibility to private.