Ease of mind when it comes to your data safety. Easily mirror your repositories to a different provider.
By hooking Gitcloner as a global webhook into your source provider, it will start listening for events. When it detects a new repository, it will create a mirror of your repository on the destination provider. It will also keep the mirror up to date when there are push events to the original repository, or when the mirror repository is updated.
- Automatically creates mirror repositories when new repositories are created
- Syncs repositories on push events to the default branch
- One-time import of repositories using the CLI
- Supports mirroring to:
- Gitea
- GitHub
- GitLab
- Prefixes mirrored repositories with original owner name
- Handles private repositories with authentication
- Docker support for easy deployment
- Automatically updates mirrors when the original repository is updated
The default mode runs a webhook server that listens for repository events and automatically creates/updates mirrors.
./gitcloner
-
Pull the image from GitHub Container Registry:
docker pull ghcr.io/janyksteenbeek/gitcloner:latest
-
Create a
.env
file with your configuration:cp .env.example .env
-
Run with Docker Compose:
docker-compose up -d
-
Clone the repository:
git clone https://github.com/janyksteenbeek/gitcloner.git cd gitcloner
-
Copy and configure environment variables:
cp .env.example .env
-
Build and run:
go build ./cmd/gitcloner ./gitcloner
Install Supervisor to run the service in the background. More info here.
PORT
: The port the webhook server will listen on (default: 8080)DESTINATION_TYPE
: Either "gitea", "github", or "gitlab"DESTINATION_URL
: The URL of your destination instanceDESTINATION_TOKEN
: API token with repository creation permissionsDESTINATION_ORG
: The organization/owner name where mirrors will be createdSOURCE_TOKEN
: Token for accessing private source repositoriesALWAYS_PUSH
: Whether to push to the destination even if the mirror already exists. By default, this is ommited.
In Gitea organization settings, add a Gitea webhook with:
- URL:
http://your-server:8080/webhook
- Method: POST
- Events: Repository Created, Push
- Branch filter: *
In GitHub organization settings, add webhook with:
- URL:
http://your-server:8080/webhook
- Content type:
application/json
- Events: Repository, Push
In GitLab group settings, add webhook with:
- URL:
http://your-server:8080/webhook
- Triggers: Project events, Push events
- SSL verification: Optional
You can use Gitcloner to import one or more repositories using the CLI:
# Mirror multiple GitHub repositories
./gitcloner --import "github octocat/Hello-World,golang/go,kubernetes/kubernetes"
# Mirror a GitLab repository
./gitcloner --import "gitlab gitlab-org/gitlab"
The import command requires:
- The
--import
flag - Platform name (
github
,gitlab
, orgitea
) - One or more repository paths in
username/repo
format, separated by commas
Note: When importing multiple repositories, if one import fails, the process will continue with the remaining repositories.
Make sure you have valid environment variables in the .env
file
Mirrored repositories are created with the format: originalOwner-repoName
Example:
- Original:
janyksteenbeek/myrepo
- Mirrored:
yourbackuporg/janyksteenbeek-myrepo
For private repositories, you need to set the SOURCE_TOKEN
environment variable. This token needs to have access to the private repositories you want to mirror.
Make sure the token has the necessary permissions for the source provider. Read more about the permissions needed in the documentation of the source provider. Most of the times, it's just a matter of read/write access to the repositories and organizations & users scopes.
Licensed under the MIT License.