Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ As an example let's create a file, `config.json`. This file should contain the t
}
```

#### Choose some repositories to exclude from the backup.

By default, all repositories you have read access to are backed up. To exclude some repos, add `exclude-repos` to `config.json`:

```
{
"token": "6b86190dd45c57c1a1b039a5a54d892e019102f7",
"directory": "~/backups/github.com",
"exclude-repo": ["dont-need-this-repo", "forked-repo-to-skip", "the-giant-repo-to-skip"]
}
```
Keep in mind that if a repo has already been backed up it will not be deleted. But it will no longer continue to be updated with subsequient backups. You could manually delete the excldued repository and it would not come back when you run the backup script again, as the repository was excluded.


#### Choose users and organizations to back up

By default, all repositories you have read access to are backed up. To choose which users' and organizations' repos are backed up, add `owners` to `config.json`:
Expand Down
5 changes: 5 additions & 0 deletions backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def main():
with open(args.config, "rb") as f:
config = json.loads(f.read())

excluded_repos_list = config.get("exclude-repo")
owners = config.get("owners")
token = config["token"]
path = os.path.expanduser(config["directory"])
Expand All @@ -94,10 +95,14 @@ def main():
if owners and owner not in owners:
continue

if name in excluded_repos_list:
continue

owner_path = os.path.join(path, owner)
mkdir(owner_path)
mirror(name, clone_url, owner_path, user["login"], token)


if __name__ == "__main__":
main()

1 change: 1 addition & 0 deletions config.json.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"token": "0123456789abcdef0123456789abcdef",
"directory": "~/backups/github.com"
"exclude-repo": ["", ""]
}