gitea icon indicating copy to clipboard operation
gitea copied to clipboard

feature, bulk importing of repositories

Open bradder555 opened this issue 8 years ago • 49 comments

Recently i hacked about in the back-end and database to migrate all of our stash repositories and jam these into gitea.

It's not an operation that i'll need to repeat, as far as i can tell in the documentation there's no procedure for doing this sort of thing.

I was thinking, as a feature, it might be handy to have an "upload zip" for migration to facilitate easy migration from other git servers.

I'm sure there're higher priorities, but figured it would make it easier for people to migrate and adopt gitea.

Thanks

bradder555 avatar Sep 22 '17 04:09 bradder555

You can do migrations via API. Write some scripts to do that.

lunny avatar Sep 22 '17 05:09 lunny

Such migrations should be done in scripts or external tools but should not be part of main gitea repo

lafriks avatar Sep 22 '17 12:09 lafriks

Any pointers to valid Github-to-Gitea scripts? I come up empty.

tacotexmex avatar Jun 09 '18 16:06 tacotexmex

@tacotexmex currently @JonasFranzDEV has a really good one: https://git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator

techknowlogick avatar Jun 09 '18 16:06 techknowlogick

Thank you very much @tecknowlogick. * quietly thinking how I could’ve discovered this selfhosted gem without your help, dreaming of a federation of Gitea instances, Mastodon-style *

tacotexmex avatar Jun 09 '18 16:06 tacotexmex

@tacotexmex you are very welcome. Currently there is a working group that is dedicated to solving the issue of federated services. I actually just spent the morning catching up on discussions from the group. If you want to follow along you can see: https://github.com/git-federation/gitpub/issues/5 Unrelated to federation we have a discord channel where the above tool was posted to.

techknowlogick avatar Jun 09 '18 17:06 techknowlogick

Such migrations should be done in scripts or external tools but should not be part of main gitea repo

@lafriks why? i think migration should be as simple as possible.

imagine a workflow like this:

  1. login to gitea with github
  2. click "import from github"
  3. select repos you want to import (all selected by default)
  4. wait some seconds (or minutes) ... migration done

if load on the gitea server could be a problem, a queue could be implemented.

davidak avatar Jul 09 '18 21:07 davidak

@davidak while I agree that it should be as simple as possible but if we implement imports from github/bitbucket/gitlab etc it will be hard keep up with their api changes. There is example that it can be easily done outside of Gitea main code base - https://git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator

Of course there are few things that we need to implement in Gitea API to have possibility to import more data but that's other thing

lafriks avatar Jul 11 '18 13:07 lafriks

Anyone have a mirror or copy of https://git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator ? The site is throwing a 500 error when trying to either clone the repo locally or even download the source code.

xeddmc avatar Sep 10 '18 16:09 xeddmc

@JonasFranzDev your server has problems ;)

lafriks avatar Sep 10 '18 16:09 lafriks

Edit, use at your own risk and don't randomly download zips from the internet.

techknowlogick avatar Sep 10 '18 16:09 techknowlogick

Cheers guys, thanks 😄

xeddmc avatar Sep 11 '18 19:09 xeddmc

https://git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator is back up and states:

This repository got moved to the offical Gitea server and will be developed there. https://gitea.com/gitea/migrator/

I just tested it, it worked flawlessly (Debian 9/10)

apt update
apt install make golang go-dep git make
go get gitea.com/gitea/migrator
cd go/src/gitea.com/gitea/migrator
dep ensure -v
make build

sudo -u gitea ./gitea-github-migrator migrate --gh-repo my/project --gh-token $GITHUB_PERSONAL_TOKEN --url https://example.com/gitea --token $GITEA_API_TOKEN

Edit: limitation: doesn't import pull requests/release notes. Didn't create the project as "mirror" (no automatic pulls in the future).

Repository, issues, tags, wiki were imported correctly. Operation took 11 minutes on a github project with 1300 issues.

nodiscc avatar Jul 15 '19 12:07 nodiscc

For others coming to this issue, the migration functionality is now built into gitea itself.

techknowlogick avatar Jul 15 '19 14:07 techknowlogick

@techknowlogick you mean using the + New migration action?

This doesn't import issues/wiki for me, only the git repository.

nodiscc avatar Jul 15 '19 17:07 nodiscc

@nodiscc @techknowlogick is right. You can migrate almost all things from github.

When you input a github URL on migration UI, and put a username/password or token/, then you will find some migrations options displayed, you can check issues/wiki/pull requests/milestones/labels .

Of course you have to have v1.9 or above.

lunny avatar Jul 16 '19 01:07 lunny

@lunny my bad, I'm on 1.8.0, still have to upgrade. I will definitely try this (my gripe was it didn't set up the repository as mirror and there was no way to change it after the fact).

By the way, thank you and all contributors for the hard work on Gitea. I'm in the process of moving all my projects to a self-hosted Gitea instance (with automatic Github/Gitlab mirrors through hooks), it has been great so far. You can find my ansible role to install gitea here (inspired from [1], [2]).

nodiscc avatar Jul 17 '19 17:07 nodiscc

I think this issue can be closed as bulk import/migration is perfectly doable using https://gitea.com/gitea/migrator/ (which is linked at https://docs.gitea.io/en-us/third-party-tools/) - or one by one from the web interface.

nodiscc avatar Jul 17 '19 18:07 nodiscc

@lunny ping

nodiscc avatar Dec 15 '19 15:12 nodiscc

@nodiscc Currently we can import almost all things of one repository from github, but maybe this issue is importing many repositories on one operation.

lunny avatar Dec 16 '19 00:12 lunny

I would say this is a feature for tea link: https://gitea.com/gitea/tea/issues/22

6543 avatar Dec 17 '19 16:12 6543

PS: when tea reaches v1.0 we can add it to gitea docs as tool to automate/do stuff via CLI ...

6543 avatar Dec 17 '19 16:12 6543

Currently the suggested "https://gitea.com/gitea/migrator/" shows:

This tool is no longer maintained and got replaced by the migration functionality in Gitea. 
Please use the "New migration" menu to migrate your GitHub repositories including issues, pullrequests etc.

But "new migration" inside gitea does only migrate a single repository, so this does not help much if one has to migrate hundreds of repos.

csarn avatar Sep 25 '20 06:09 csarn

@csarn and others. this is true I wanted to bulk migrate repo's but migratory is 1 repo at a time???

what to do?

ameeno avatar Mar 05 '21 13:03 ameeno

@ameeno best way at the moment: use API via go-sdk or curl ... script

6543 avatar Mar 05 '21 14:03 6543

The other option is to use adopt repository if the repositories are in the right place with the correct names.

zeripath avatar Mar 05 '21 18:03 zeripath

anyone have a script ready for batch migration? I found a Chinese one on awesome-gitea but I am having problems with it it only working for orgs.

ameeno avatar Mar 06 '21 00:03 ameeno

I need to bulk import 80+ repositories from GitLab to Gitea - any pointers for how this could be done? Thanks a lot!

andreas-bulling avatar Oct 30 '22 08:10 andreas-bulling

I need to bulk import 80+ repositories from GitLab to Gitea - any pointers for how this could be done? Thanks a lot!

You can do it via some scripts with migration API.

lunny avatar Oct 31 '22 01:10 lunny

sure, I know this is possible. Has anybody written any such script? I couldn't find one... :/

andreas-bulling avatar Oct 31 '22 08:10 andreas-bulling