[MIRROR] Effortlessly migrate GitHub repositories to Codeberg! Seamlessly transfer project. Powered by Bash, curl, and jq.
|
Rahul Martim Juliato
78f3c986f3
fix: properly escape repo descriptions in JSON payload
Use jq to build the migration request body instead of shell string interpolation, preventing 422 errors when descriptions contain special characters (e.g. double quotes). Also improve error output to display the actual message returned by Codeberg instead of just the HTTP status code. Probably fixes #3 too. |
||
|---|---|---|
| LICENSE | Initial commit | |
| migrate_github_to_codeberg.sh | fix: properly escape repo descriptions in JSON payload | |
| README.org | doc: update script name | |
GitHub to Codeberg Migration Script
Overview
This script automates the migration of GitHub repositories to Codeberg. It allows you to seamlessly transfer your projects from GitHub to Codeberg while preserving their metadata, such as descriptions and access permissions.
Features
- Migrate all or selected repositories from GitHub to Codeberg.
- Customizable prefix for repository descriptions.
- Customizable filter for repository owners.
- Supports pagination for fetching large numbers of repositories.
- Error handling for repository migration failures.
Limitations
Due to the complex nature of both Github and Codeberg apis, it was a design choice for this script to omit several features like:
- distinction between forks and original repositories
- wiki
- pull requests
- avatars for projects
...and so on. Please modify this script to your own needs.
Usage
Configure User Settings
- Open the script file (
migrate_github_to_codeberg.sh) in a text editor. - Update the user configuration section with your GitHub and Codeberg credentials.
- Optionally, define the repositories you want to migrate by adding
their names to the
REPOSITORIESarray. - Optionally, define the owners of the repositories that you want to
migrate by adding their usernames to the
OWNERSarray.
Install Dependencies
-
Ensure that
curlandjqare installed on your system.- On Debian/Ubuntu:
sudo apt install curl jq - On macOS with Homebrew:
brew install curl jq
- On Debian/Ubuntu:
Run the Script
- Execute the script by running
./migrate_repositories.shin your terminal. - Follow the on-screen instructions to proceed with the migration.
- Press ENTER to start the migration process.
Monitor Progress
- The script will display information about the migration progress, including successful migrations and any errors encountered.
Review Results
- Once the migration is complete, review the results to ensure all desired repositories have been migrated successfully.
Requirements
- Bash shell
- curl
- jq (JSON processor)
Screenshots (in text mode)
----------------------------------------------
Welcome to Github to Codeberg Migration Script
----------------------------------------------
User on Github : LionyxML
User on Codeberg : LionyxML
Using description prefix: [MIRROR]
Migrating repos owned by: all users
Migrating repo : aa
Migrating repo : dotfiles
Migrating repo : flycheck
Migrating repo : my_emacs_config
If you wish to change this, abort and change this script.
Press ENTER to continue, C-c to abort.
>>> Working...
>>> Migrating: aa... Error! Already exists on Codeberg.
>>> Migrating: flycheck... Success!
>>> Migration complete!
----------------------------------------------
Welcome to Github to Codeberg Migration Script
----------------------------------------------
User on Github : LionyxML
User on Codeberg : LionyxML
Using description prefix: [MIRROR]
Migrating repos owned by: LionyxML
Migrating repo : all
If you wish to change this, abort and change this script.
Press ENTER to continue, C-c to abort.
>>> Working...
>>> Migrating: 100_computer_science_concepts... Error! Already exists on Codeberg.
>>> Migrating: 10_design_patterns... Error! Already exists on Codeberg.
>>> Migrating: aa... Error! Already exists on Codeberg.