# gitbackup
Backup all your Git (Gitea, Forgejo, GitLab, GitHub) repositories with a single command.
## How to install
```
cargo install gitbackup && gitbackup init
```
### Config file
You can retrieve the config file location with the `config` command. The file is constructed with the following
structure:
```toml
backup_path = "gitarchive"
[[providers]]
provider = "github"
host = "github.com"
exclude = ["facebook/react", "^google/"]
username = "MY_USERNAME"
token = "MY_GITHUB_TOKEN"
[[providers]]
provider = "gitlab"
host = "gitlab.com"
exclude = []
username = "MY_USERNAME"
token = "MY_GITLAB_TOKEN"
[[providers]]
provider = "forgejo"
host = "codeberg.org"
exclude = []
username = "MY_USERNAME"
token = "MY_FORGEJO_TOKEN"
```
The `backup_path` field is the path where the repositories will be stored related to the user directory.
The `providers` field is a list of providers to backup. Each provider has the following fields:
- `provider`: the provider of the repository (`github`, `gitea`, `forgejo`, `gitlab` are supported)
- `host`: the host of the repository (e.g.: github.com, gitlab.com, codeberg.org, ... )
- `exclude`: a list of repositories to exclude from the backup seperated by a comma (we can also use a regex)
- `username`: your username
- `token`: your token
## How to use
```
~ gitbackup help
gitbackup 0.1.0
Adrian Tombu <adrian@otso.fr>
Backup all your git repositories with a single command
Usage: gitbackup <COMMAND>
Commands:
init Initialize the config file
config Display the config file contents
run Run the backup
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
```
## How to retrieve credentials
### How to create a Github personal access token
1. Go to https://github.com/settings/tokens (Settings -> Developer settings -> Personal access tokens -> Tokens (
classic))
2. Click on the "Generate new token" button
3. Click on the "repo - Full control of private repositories" checkbox
4. Click on the "Generate token" button
5. Save your newly generated token on a safe place, this will be the last time it is shown to you
### How to create a GitLab personal access token
1. Go to https://gitlab.com/-/user_settings/personal_access_tokens (Settings -> Access tokens)
2. Click on the "Add new token" button
3. Click on the "read_api" checkbox
4. Click on the "Create personal access token" button
5. Save your newly generated token on a safe place, this will be the last time it is shown to you
### How to create a Gitea / Forgejo personal access token
There can be many instances of Gitea / Forgejo so here we will use Codeberg as an example.
1. Go to https://codeberg.org/user/settings/applications (Settings -> Applications)
2. Give a name to your token, and click on "Select permissions"
3. Select "Read" in the "Organization", "Repository" and "User" sections
4. Click on the "Generate token" button
5. Save your newly generated token on a safe place, this will be the last time it is shown to you