Skip to content

Conversation

@lunny
Copy link
Member

@lunnylunny commented Jul 14, 2020

Currently online migrating is possible but in fact, it depends on the internet network status what's a mess. This PR makes it possible to dump a repository on GitHub/GitLab/Gitea to a disk directory and then transfer it to another Gitea instance via the possible transfer method. And then restore the repository on the target Gitea instance.

i.e. Gitea repository itself in GitHub spent about 80 GB but transfer 80GB online is almost impossible. Then we can dump the repository to a host nearby Github's host and then compress it and transfer it to another host.

A new Gitea command has been added to do the things, you can use it as below:

./gitea dump-repo --repo_dir ./dumps --clone_addr https://github.com/go-xorm/builder.git --auth_username <token> --owner_name xorm --repo_name builder 

A dumped repository(go-gitea/test_repo) directory structure like this.

图片

Another command is restore-repo added from this PR which could restore the repository to a Gitea instance from the dumped folder.

./gitea restore-repo --repo_dir ./dumps/xorm/builder --owner_name xorm --repo_name builder 

And this could be also used as a backup tool to backup repositories in Github/Gitlab/Gitea .

  • Add a command gitea dump-repo
  • Add a command gitea restore-repo

@lunnylunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jul 14, 2020
@lunnylunny added this to the 1.13.0 milestone Jul 14, 2020
@lunnylunnyforce-pushed the lunny/dump_repository branch from f98c0fa to 041836fCompareJuly 18, 2020 07:57
@lunnylunny changed the title WIP: Dump github/gitlab repository data to a local directoryDump github/gitlab repository data to a local directoryJul 18, 2020
@6543
Copy link
Member

6543 commented Jul 27, 2020

@lunny one thing left: we should also save the git-service type and source url somewhere

@GiteaBotGiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 27, 2020
@6543
Copy link
Member

6543 commented Jul 27, 2020

... to be able to migrate issue/pull ownership to existing users as we can do with the normal github/gitlab migration now

@lunnylunnyforce-pushed the lunny/dump_repository branch from ca69b71 to 0c29eeeCompareAugust 20, 2020 08:50
@codecov-commenter
Copy link

codecov-commenter commented Aug 21, 2020

Codecov Report

Merging #12244 into master will increase coverage by 0.66%.
The diff coverage is 1.49%.

Impacted file tree graph

@@ Coverage Diff @@## master #12244 +/- ## ========================================== + Coverage 42.59% 43.25% +0.66%  ========================================== Files 671 645 -26 Lines 73635 71468 -2167 ========================================== - Hits 31365 30917 -448 + Misses 37184 35543 -1641 + Partials 5086 5008 -78 
Impacted FilesCoverage Δ
cmd/dump_repo.go0.00% <0.00%> (ø)
modules/migrations/base/pullrequest.go0.00% <ø> (ø)
modules/migrations/dump.go0.00% <0.00%> (ø)
modules/structs/repo.go54.54% <ø> (+4.54%)⬆️
modules/migrations/migrate.go22.47% <41.66%> (+0.91%)⬆️
routers/api/v1/settings/settings.go44.44% <0.00%> (-55.56%)⬇️
modules/storage/local.go0.00% <0.00%> (-38.10%)⬇️
modules/queue/queue.go24.39% <0.00%> (-7.87%)⬇️
models/attachment.go54.86% <0.00%> (-6.25%)⬇️
modules/webhook/matrix.go30.30% <0.00%> (-4.67%)⬇️
... and 208 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54dd28f...5342029. Read the comment docs.

@techknowlogick
Copy link
Member

please resolve conflict

@lunnylunnyforce-pushed the lunny/dump_repository branch 2 times, most recently from 4ffbe89 to af69f37CompareSeptember 9, 2020 11:04
@techknowlogick
Copy link
Member

CI fail is related:

level=warning msg="[runner] Can't run linter goanalysis_metalinter: S1008: failed prerequisites: [([email protected]/gitea/modules/cron, [email protected]/gitea/modules/cron): analysis skipped: errors in package: [/go/src/code.gitea.io/gitea/modules/cron/tasks_basic.go:12:2: could not import code.gitea.io/gitea/modules/migrations (/go/src/code.gitea.io/gitea/modules/migrations/dump.go:514:29: cannot use downloader (variable of type *RepositoryRestorer) as base.Downloader value in argument to DoMigrateRepository: wrong type for method GetAsset)]]" level=warning msg="[runner] Can't run linter unused: buildir: analysis skipped: errors in package: [/go/src/code.gitea.io/gitea/modules/migrations/dump.go:514:29: cannot use downloader (variable of type *RepositoryRestorer) as base.Downloader value in argument to DoMigrateRepository: wrong type for method GetAsset -: could not load export data: no export data for \"code.gitea.io/gitea/modules/migrations\"]" level=error msg="Running error: buildir: analysis skipped: errors in package: [/go/src/code.gitea.io/gitea/modules/migrations/dump.go:514:29: cannot use downloader (variable of type *RepositoryRestorer) as base.Downloader value in argument to DoMigrateRepository: wrong type for method GetAsset -: could not load export data: no export data for \"code.gitea.io/gitea/modules/migrations\"]" 

@6543
Copy link
Member

6543 commented Sep 10, 2020

I think we should stave CloneURL to yaml too
why not move Topics into a generell repo.yml ?
so the local "import" still has the right urls ...

@lunnylunnyforce-pushed the lunny/dump_repository branch from af69f37 to b7f185aCompareSeptember 11, 2020 13:10
@lunnylunny changed the title Dump github/gitlab repository data to a local directoryWIP: Dump/restore github/gitlab repository data to a local directorySep 11, 2020
@lunnylunny modified the milestones: 1.13.0, 1.14.0Sep 11, 2020
@lunnylunny changed the title WIP: Dump/restore github/gitlab repository data to a local directoryWIP: Dump/restore github/gitlab repository data to a local directory and restore to giteaSep 17, 2020
@lunnylunny mentioned this pull request Sep 17, 2020
20 tasks
@lunnylunnyforce-pushed the lunny/dump_repository branch from 7ad9edd to 5342029CompareOctober 2, 2020 14:17
@lunnylunnyforce-pushed the lunny/dump_repository branch from 5342029 to 48d24d2CompareOctober 18, 2020 03:06
@codecov-io
Copy link

codecov-io commented Oct 19, 2020

Codecov Report

Merging #12244 (695d23e) into master (cf9d471) will decrease coverage by 0.29%.
The diff coverage is 3.25%.

Impacted file tree graph

@@ Coverage Diff @@## master #12244 +/- ## ========================================== - Coverage 42.36% 42.06% -0.30%  ========================================== Files 728 733 +5 Lines 78015 78666 +651 ========================================== + Hits 33049 33093 +44 - Misses 39540 40159 +619 + Partials 5426 5414 -12 
Impacted FilesCoverage Δ
cmd/dump_repo.go0.00% <0.00%> (ø)
cmd/restore_repo.go0.00% <0.00%> (ø)
models/admin.go60.31% <0.00%> (-8.78%)⬇️
models/task.go34.95% <ø> (+0.04%)⬆️
modules/migrations/base/downloader.go17.51% <ø> (ø)
modules/migrations/base/pullrequest.go0.00% <ø> (ø)
modules/migrations/dump.go0.00% <0.00%> (ø)
modules/migrations/error.go100.00% <ø> (ø)
modules/migrations/git.go46.42% <ø> (+3.09%)⬆️
modules/migrations/gitea_downloader.go0.91% <0.00%> (+<0.01%)⬆️
... and 29 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 212fa34...695d23e. Read the comment docs.

@6543
Copy link
Member

6543 commented Oct 19, 2020

@lunny "migrations/restore.go exported methods should have comment or be unexported"

@lunnylunnyforce-pushed the lunny/dump_repository branch 2 times, most recently from f9b17ae to 13717d8CompareOctober 21, 2020 04:49
@lunnylunnyforce-pushed the lunny/dump_repository branch from b1aab92 to 695d23eCompareDecember 27, 2020 02:23
@lunny
Copy link
MemberAuthor

@techknowlogick done.

@GiteaBotGiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 27, 2020
@lunnylunny merged commit dd08853 into go-gitea:masterDec 27, 2020
@lunnylunny deleted the lunny/dump_repository branch December 27, 2020 03:34
@delvhdelvh mentioned this pull request Jan 28, 2021
12 tasks
@go-giteago-gitea locked and limited conversation to collaborators Feb 11, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.topic/repo-migrationMigrate repos from other platforms to Gitea, or from Gitea to themtype/featureCompletely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@lunny@6543@codecov-commenter@techknowlogick@codecov-io@a1012112796@GiteaBot