36 lines
992 B
Python
36 lines
992 B
Python
import os
|
|
|
|
url = "http://192.168.137.66:3000/taynpg/"
|
|
backup_name = "gitea_backup"
|
|
|
|
current_path = os.getcwd()
|
|
print("Current:" + current_path)
|
|
parent_path = os.path.dirname(current_path)
|
|
print("Parent:" + parent_path)
|
|
config_path = os.path.join(current_path, "repo_list.txt")
|
|
|
|
if not os.path.exists(config_path):
|
|
print("repo_list.txt not found.")
|
|
exit()
|
|
|
|
backup_path = os.path.join(parent_path, backup_name)
|
|
print("Backup Path:" + backup_path)
|
|
|
|
if not os.path.exists(backup_path):
|
|
os.makedirs(backup_path)
|
|
|
|
with open(config_path, "r", encoding="utf-8") as f:
|
|
content = f.readlines()
|
|
|
|
for repo in content:
|
|
repo_name = repo.replace("\n", "")
|
|
purpose_dir = os.path.join(backup_path, repo_name)
|
|
if not os.path.exists(purpose_dir):
|
|
os.makedirs(purpose_dir)
|
|
cmd = "git clone " + url + repo_name + ".git"
|
|
cmd = cmd + " \"" + purpose_dir + "\""
|
|
else:
|
|
cmd = "cd /d \"" + purpose_dir + "\" && git pull"
|
|
print(cmd)
|
|
os.system(cmd)
|