Scripts Module to mirror gitblit
This package requires at least python 3.6.
NOTE: This package is created for education only, not intended to be used in productive system!
The class mirror_gitblit.GitblitMirror.Gitblit provides methods to
talk to a Gitblit-Server via its RPC-API.
To use this class, the command curl and git must available in the PATH-Variable.
One can test if these commands exist by using which. One possible output:
$ which curl
/usr/bin/curl
$ which git
/usr/bin/git
Example
Running this file (after change some variables) will create at least these files:
${HOME}/mirror-log.txt,f'{backupdir}/{HOST}-repos.json'
and mirror of repositories in remote gitblit server --if any-- which are less than 1 GB,
in {backupdir}.
# This script is written by an admin. It uses `mirror-gitblit` to mirror
# repositories of a gitblit-server
from mirror_gitblit.GitblitMirror import Gitblit
from mirror_gitblit import GitblitMirror
import logging
HOME = "/home/backup"
HOST = "gitblit"
DOMAIN = "somedomain.de"
GIT_SSH_PORT=8022
user = "backup"
source_web_url = f"https://{HOST}.{DOMAIN}/gitblit"
curl_credentials_file = f'{HOME}/curl-credential.txt'
source_base_url = f'ssh://{user}@{HOST}.de:{GIT_SSH_PORT}'
backup_dir = "/backup"
repositories_json = f"{backup_dir}/{HOST}-repos.json"
included_repos = [
# name of repositories to be included without leading slash (/)
]
excluded_repos = [
# name of repositories to be excluced without leading slash (/)
]
logging.basicConfig(filename=f"{HOME}/mirror-log.txt",
filemode='w', level=logging.INFO,
format='%(asctime)s - %(levelname)6s - %(message)s',
datefmt="%Y-%m-%dT%H:%M:%S%z")
gitblit = Gitblit(source_web_url, curl_credentials_file, source_base_url, repositories_json, backup_dir)
gitblit.download_repositories_list()
repo_filter = lambda repo : GitblitMirror.inclusive_exclusive_filter(repo, None, excluded_repos)
less_than_1GB = lambda repo: GitblitMirror.repo_size_to_int(repo) < 1000**3
less_than_2MB = lambda repo: GitblitMirror.repo_size_to_int(repo) < 2 * (1000**2)
gitblit.clone_repos(less_than_1GB, False)
gitblit.update_repos(less_than_1GB)
- One must also create a file named
$HOME/curl-credentials.txt, which contents authentication information against gitblit server in netrc format:
machine {gitblit.domain} login {username} password {user password}
This file is passed to cURL-Option --netrc-file. To test if your netrc file is
correct run
curl --netrc-file $HOME/curl-credentials.txt https://gitblit.domain.de/gitblit/rpc/?req=LIST_REPOSITORIES
- The SSH-public key of the gitblit user must be imported in Gitblit server.
Metadata
Release files for mirror-gitblit 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mirror-gitblit-0.2.0.tar.gz | 6.2 kB | Without provenance | Details for mirror-gitblit-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mirror_gitblit-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for mirror_gitblit-0.2.0-py3-none-any.whl |
Total release size: 12.1 kB
Release files / mirror-gitblit-0.2.0.tar.gz
| Download URL | mirror-gitblit-0.2.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
199e57de417ae62ddf971e65406bce0edbfe92d2589d993fe2c9021e2ce6be93
|
|
BLAKE2b-256 checksum How to use checksums |
1177287660dbae6bf05c9a534d7f86ddb2d112424a86159e28c5d77d1fce0e60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Release files / mirror_gitblit-0.2.0-py3-none-any.whl
| Download URL | mirror_gitblit-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef182f056a1aad4e859c64a9e3ee3a2aa24db025a2b5f353f4817cb6ac288d3a
|
|
BLAKE2b-256 checksum How to use checksums |
47da3b9250140a6bbaeced47420d388411baabc23c599e82097c37a1cf5756e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Security for mirror-gitblit 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.