# Repository selection rules

**GitProtect provides selection rules, allowing administrators to determine which repositories and projects are included or excluded from backup and recovery tasks. Rules can be based on names, owners, creation dates, branches, or specific patterns, offering granular control over the backup scope and ensuring that only relevant repositories and projects are processed.**

***

## Selection rules and rule patterns

Below are the selection rules and rule patterns you can use in **GitProtect** to select repositories and projects for inclusion in backup jobs within your **DevOps** organization.

### <mark style="background-color:blue;">Azure DevOps & Bitbucket</mark>

1. **Repository name** — you can use the full or partial name of a repository. Wildcard characters can be used at the end of the rule to match repository names:
   1. `*` matches zero or more characters
   2. `?` matches exactly one character
2. **Project name**: protects all repositories within the specified project.

### <mark style="background-color:blue;">GitHub</mark>

1. **Repository name** — you can use the full or partial name of a repository. Wildcard characters can be used at the end of the rule to match repository names:
   1. `*` matches zero or more characters
   2. `?` matches exactly one character
2. **Topic name** — specify the exact name of a topic. For example, if you enter the topic `html`, all repositories assigned to the `html` topic will be backed up.

### <mark style="background-color:blue;">GitLab</mark>

1. **Repository name** — you can use the full or partial name of a repository. Wildcard characters can be used at the end of the rule to match repository names:
   1. `*` matches zero or more characters
   2. `?` matches exactly one character
2. **Topic name** — specify the exact name of a topic. For example, if you enter the topic `html`, all repositories assigned to the `html` topic will be backed up.
3. **Group path**: protects all repositories within the specified group or subgroup path.

***

## Selection rule examples

The following are examples of rule patterns, along with brief explanations:

* **Pattern:** `yourorganization/*`
  * This will match all repositories in the organization named `yourorganization`.
* **Pattern:** `yourorganization/n??`
  * Matches repositories where `n` is followed by exactly **two characters**.

***

## Regular expression patterns (regex)

All selection rules can use **regular expression patterns** (**regex**).

Regular expressions let you create flexible and adaptable rules that align with your organization's naming conventions. This approach allows precise targeting and automation based on consistent patterns in repository or project names.

The following are illustrative examples of how these rules can be applied, although the available configurations extend well beyond these cases:

* **Pattern:** `yourorganization/repo[0-9]+`
  * This will match repositories such as `repo1`, `repo12`, `repo123`, and so on.
* **Pattern:** `yourorganization/.*data.*`&#x20;
  * Matches any repository name containing the word `data`.
* **Pattern:** `yourorganization/(?!.*data.*)`
  * Excludes any repository name that contains the word `data`.
