diff --git a/README.md b/README.md index d1f151e..b18e9d4 100644 --- a/README.md +++ b/README.md @@ -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`: diff --git a/backup.py b/backup.py index 1e23d13..5652034 100644 --- a/backup.py +++ b/backup.py @@ -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"]) @@ -94,6 +95,9 @@ 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) @@ -101,3 +105,4 @@ def main(): if __name__ == "__main__": main() + diff --git a/config.json.example b/config.json.example index f5522fb..8dc6f72 100644 --- a/config.json.example +++ b/config.json.example @@ -1,4 +1,5 @@ { "token": "0123456789abcdef0123456789abcdef", "directory": "~/backups/github.com" + "exclude-repo": ["", ""] }