From 3d34c7dc1645fdacd4289008902ef16e11b57cf8 Mon Sep 17 00:00:00 2001 From: henri Date: Fri, 1 Mar 2024 21:52:08 +1300 Subject: [PATCH 1/4] added basic support for excluding repositories --- backup.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backup.py b/backup.py index 1e23d13..6c2354b 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,10 @@ def main(): if owners and owner not in owners: continue + if name in excluded_repos_list: + print("excluded repo :", name) + continue + owner_path = os.path.join(path, owner) mkdir(owner_path) mirror(name, clone_url, owner_path, user["login"], token) @@ -101,3 +106,4 @@ def main(): if __name__ == "__main__": main() + From 87c1d0bbfb11eb17438a09240b02f2f2ec65e9a5 Mon Sep 17 00:00:00 2001 From: henri Date: Fri, 1 Mar 2024 21:53:12 +1300 Subject: [PATCH 2/4] removed some debug information --- backup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backup.py b/backup.py index 6c2354b..5652034 100644 --- a/backup.py +++ b/backup.py @@ -96,7 +96,6 @@ def main(): continue if name in excluded_repos_list: - print("excluded repo :", name) continue owner_path = os.path.join(path, owner) From c1d55be7eabfe1d78f8dad47e5230a9246505590 Mon Sep 17 00:00:00 2001 From: henri Date: Fri, 1 Mar 2024 21:56:37 +1300 Subject: [PATCH 3/4] updated example config file to include exclude-repo option Just add in as many repos as you would like to exclude. This has only been tested with user personal repos. Your mileage may vary with organizations etc. Use at your own risk. --- config.json.example | 1 + 1 file changed, 1 insertion(+) 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": ["", ""] } From 8ca5f16fed5b936985ed7b0e329111d1a6eed19b Mon Sep 17 00:00:00 2001 From: henri Date: Mon, 4 Mar 2024 10:22:08 +1300 Subject: [PATCH 4/4] Updates README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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`: