Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zekroTJA/stargrab
Securely mirror your starred repositories.
https://github.com/zekroTJA/stargrab
github hacktoberfest python starred-repositories stars
Last synced: about 7 hours ago
JSON representation
Securely mirror your starred repositories.
- Host: GitHub
- URL: https://github.com/zekroTJA/stargrab
- Owner: zekroTJA
- License: mit
- Created: 2022-01-20T09:37:08.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-13T09:21:30.000Z (over 1 year ago)
- Last Synced: 2024-08-01T22:02:53.830Z (3 months ago)
- Topics: github, hacktoberfest, python, starred-repositories, stars
- Language: Python
- Homepage:
- Size: 3.09 MB
- Stars: 32
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- project-awesome - zekroTJA/stargrab - Securely mirror your starred repositories. (Python)
README
---
This little python script fetches all your starred repositories from your GitHub account and clones them to your server so you will never lose important resources!
# Usage
This script is designed to be used with cron. So, first of all, please install cron if it is not already installed.
You can configure the script either via environment variables (keys uppercase with `SG_` as prefix) or via a configuration file located in the current work directory, in your home directory at `.stargrab/config.*` or at `/etc/stargrab/config.*`. Both `yaml` and `json` files are accepted as config file formats.
These are the available configurations.
| Key | Type | Required | Description |
|-----|------|----------|-------------|
| `github_token` | `string` | Yes | The GitHub API token to authenticate you against the API. It can be obtained from [here](https://github.com/settings/tokens). |
| `target` | `string` | No (default: `repositories`) | The target location where repository mirros should be stored. |
| `user` | `string` | No (default: `viewer`) | The user to grab starred repositories from. Defaultly, this will be the user authenticated with the GitHub token. |
| `ignore` | `string` | No | A regular expression applied on the lowercased `username/reponame` of each repository. When it matches, the repository is ignored. |
| `depth` | `number` | No | Specify a maximum commit depth for repositories on initial clone. |
| `max_size` | `string` or `number` | No | Filter repositories for maximum disk size. Only repos that are smaller than this value will be stored. |## Run barely
Of course, you need python3 and git to be installed on your system.
Now, clone the repository into your home directory.
```
git clone https://github.com/zekrotja/stargrab ~/stargrab
```Then, you want to install the required dependencies of the script.
```
python3 -m pip install -r ~/stargrab/requirements.txt
```After that, create a location to store the repository mirrors to.
```
mkdir ~/stargrab_repos
```Following, create the config in your home directory and enter your configuration.
```
mkdir ~/.stargrab
vim ~/.stargrab/config.yml
```Next, create a crontab entry to execute the script periodically.
```
crontab -e
```The entry could look like following. This will execute the mirroring every day at 3am.
```
0 3 * * * python3 /home//stargrab/stargrab/main.py >> /home//stargrab/log 2>&1
```## Run with Docker
Therefore, you need Docker to be installed on your system, of course.
First, pull the image from GHCR.
```
docker pull ghcr.io/zekrotja/stargrab:latest
```Optionally, you can now tag the image for simplicity.
```
docker tag ghcr.io/zekrotja/stargrab:latest stargrab:latest
```Next, create a crontab entry to execute the Docker image periodically.
```
crontab -e
```The entry could look like following. This will execute the mirroring every day at 3am.
```
0 3 * * * docker run --rm --env SG_GITHUB_TOKEN="" -v /home//stargrab_repos:/var/repos stargrab
```