From 482b5585eda4ee6658a9ac05c316cc91c5e6ad8a Mon Sep 17 00:00:00 2001 From: Johannes Alneberg Date: Thu, 6 Feb 2025 17:17:50 +0100 Subject: [PATCH 1/2] Access token is needed for private repos --- backup_github.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/backup_github.py b/backup_github.py index 91d3837..5d57690 100755 --- a/backup_github.py +++ b/backup_github.py @@ -74,11 +74,10 @@ def backup(user, password, access_token, organizations, dest): for repository in chain(*repositories): logger.info("Github API rate limit: {}".format(github_instance.get_rate_limit())) - if password is not None and repository.private is True: + if access_token is not None and repository.private is True: source = repository.clone_url.replace( - "https://", - "https://{}:{}@".format(user, password) - ) + "https://", "https://{}:{}@".format(user, access_token) + ) else: source = repository.clone_url @@ -100,7 +99,7 @@ def backup(user, password, access_token, organizations, dest): logger.error("There was an error fetching the branches " "from the repository {}, " "skipping it".format(repository.name)) - pass + continue logger.info("Finished copying repo {}".format(repository.name)) # Otherwise clone the repository and fetch all branches else: @@ -115,7 +114,7 @@ def backup(user, password, access_token, organizations, dest): logger.error("ERROR: Error cloning repository {}, " "skipping it".format(repository.name)) logger.error(str(e)) - pass + continue try: with cd(repository_path): check_call(track_all_branches, shell=True, @@ -129,7 +128,7 @@ def backup(user, password, access_token, organizations, dest): repository.name )) logger.error(str(e)) - pass + continue def compress_and_move(source, final_dest): From 918c7c5f4e6a5a86ef826d9c6c936387aedf22dd Mon Sep 17 00:00:00 2001 From: Johannes Alneberg Date: Fri, 7 Feb 2025 08:40:33 +0100 Subject: [PATCH 2/2] Update backup_github.py Co-authored-by: Anandashankar Anil --- backup_github.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backup_github.py b/backup_github.py index 5d57690..791ca69 100755 --- a/backup_github.py +++ b/backup_github.py @@ -128,7 +128,6 @@ def backup(user, password, access_token, organizations, dest): repository.name )) logger.error(str(e)) - continue def compress_and_move(source, final_dest):