change:变更为lua脚本。
This commit is contained in:
parent
5112cc369e
commit
e992d5d01f
55
GitBackup.lua
Normal file
55
GitBackup.lua
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
-- 导入 os 模块
|
||||||
|
local os = require("os")
|
||||||
|
local io = require("io")
|
||||||
|
local fs = require("lua_fs")
|
||||||
|
|
||||||
|
local url = "https://www.sinxmiao.cn/"
|
||||||
|
local backup_name = "gitea_backup"
|
||||||
|
|
||||||
|
local current_path = fs.get_current_directory()
|
||||||
|
print("Current: " .. current_path)
|
||||||
|
|
||||||
|
local parent_path = fs.get_parent(current_path)
|
||||||
|
print("Parent: " .. parent_path)
|
||||||
|
|
||||||
|
local config_path = current_path .. "/repo_list.txt"
|
||||||
|
|
||||||
|
if not fs.exists(config_path) then
|
||||||
|
print("repo_list.txt not found.")
|
||||||
|
os.exit()
|
||||||
|
end
|
||||||
|
|
||||||
|
local backup_path = parent_path .. "/" .. backup_name
|
||||||
|
print("Backup Path: " .. backup_path)
|
||||||
|
|
||||||
|
if not fs.exists(backup_path) then
|
||||||
|
fs.mkdir(backup_path) -- 创建备份目录
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 读取 repo_list.txt 文件
|
||||||
|
local content = {}
|
||||||
|
for line in io.lines(config_path) do
|
||||||
|
table.insert(content, line)
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, repo in ipairs(content) do
|
||||||
|
local repo_name = repo:match("^(.*)$") -- 去掉换行符
|
||||||
|
|
||||||
|
if #repo_name == 0 then
|
||||||
|
print("Skipping empty repo name")
|
||||||
|
goto continue
|
||||||
|
end
|
||||||
|
|
||||||
|
local purpose_dir = backup_path .. "/" .. repo_name
|
||||||
|
local cmd
|
||||||
|
|
||||||
|
if not fs.exists(purpose_dir) then
|
||||||
|
fs.mkdir(purpose_dir) -- 创建对应的目录
|
||||||
|
cmd = "git clone --recursive " .. url .. repo_name .. ".git \"" .. purpose_dir .. "\""
|
||||||
|
else
|
||||||
|
cmd = "cd /d \"" .. purpose_dir .. "\" && git pull && git submodule update"
|
||||||
|
end
|
||||||
|
print(cmd)
|
||||||
|
os.execute(cmd) -- 执行命令
|
||||||
|
::continue:: -- 跳到下一次循环
|
||||||
|
end
|
BIN
lua_fs.dll
Normal file
BIN
lua_fs.dll
Normal file
Binary file not shown.
@ -1,22 +1,42 @@
|
|||||||
taynpg/tryreg
|
taynpg/mlua
|
||||||
taynpg/how-to-use
|
taynpg/how-to-use
|
||||||
|
taynpg/deepseek-use
|
||||||
taynpg/transm
|
taynpg/transm
|
||||||
taynpg/ofen
|
taynpg/filecomplete
|
||||||
taynpg/resource
|
semi/179
|
||||||
|
taynpg/binpack
|
||||||
|
taynpg/backup_repo
|
||||||
|
taynpg/csp_temp
|
||||||
|
taynpg/ftrans
|
||||||
|
taynpg/tooldown
|
||||||
|
taynpg/ansicon
|
||||||
taynpg/wxqm
|
taynpg/wxqm
|
||||||
|
taynpg/winu8test
|
||||||
|
taynpg/ofen
|
||||||
|
yun/nvim
|
||||||
|
taynpg/LinuxPack
|
||||||
|
taynpg/OneLevelXmlOpr
|
||||||
|
taynpg/rbs_tool
|
||||||
|
semi/GenAlarm
|
||||||
|
taynpg/xp
|
||||||
|
taynpg/fanyi
|
||||||
|
taynpg/VcpkgList
|
||||||
|
taynpg/cmt
|
||||||
|
taynpg/lanzou
|
||||||
|
taynpg/md5_sha256
|
||||||
|
taynpg/blank
|
||||||
|
taynpg/PictureTool
|
||||||
|
taynpg/BMonitor
|
||||||
|
taynpg/resource
|
||||||
|
taynpg/tryreg
|
||||||
yun/yqm
|
yun/yqm
|
||||||
taynpg/mail-cpp
|
taynpg/mail-cpp
|
||||||
taynpg/PackBinary
|
taynpg/PackBinary
|
||||||
semi/GenAlarm
|
|
||||||
taynpg/cmt
|
|
||||||
yun/LinuxPack
|
|
||||||
taynpg/msync
|
taynpg/msync
|
||||||
yun/cqm
|
yun/cqm
|
||||||
yun/yx
|
yun/yx
|
||||||
yun/nvim
|
|
||||||
yun/mail-send
|
yun/mail-send
|
||||||
yun/useopencv4
|
yun/useopencv4
|
||||||
semi/OneLevelXmlOpr
|
|
||||||
taynpg/swconfig
|
taynpg/swconfig
|
||||||
taynpg/wezterm
|
taynpg/wezterm
|
||||||
taynpg/SockGrab
|
taynpg/SockGrab
|
||||||
@ -24,9 +44,7 @@ taynpg/script
|
|||||||
taynpg/rsync-task
|
taynpg/rsync-task
|
||||||
taynpg/nettrans
|
taynpg/nettrans
|
||||||
taynpg/codecreate
|
taynpg/codecreate
|
||||||
taynpg/backup_repo
|
|
||||||
taynpg/open-cmd-here
|
taynpg/open-cmd-here
|
||||||
taynpg/binpack
|
|
||||||
taynpg/comprecpp
|
taynpg/comprecpp
|
||||||
taynpg/wxwidgetstudy
|
taynpg/wxwidgetstudy
|
||||||
taynpg/auxiliarytool
|
taynpg/auxiliarytool
|
||||||
@ -39,11 +57,3 @@ taynpg/mskip-list
|
|||||||
taynpg/ftptrans
|
taynpg/ftptrans
|
||||||
taynpg/sxtwl_cpp
|
taynpg/sxtwl_cpp
|
||||||
taynpg/SerialOpr
|
taynpg/SerialOpr
|
||||||
taynpg/PictureTool
|
|
||||||
taynpg/BMonitor
|
|
||||||
taynpg/md5_sha256
|
|
||||||
taynpg/lanzou
|
|
||||||
taynpg/filecomplete
|
|
||||||
taynpg/winu8test
|
|
||||||
taynpg/ansicon
|
|
||||||
taynpg/tooldown
|
|
35
run.py
35
run.py
@ -1,35 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
url = "https://www.sinxmiao.cn/"
|
|
||||||
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 --recursive " + url + repo_name + ".git"
|
|
||||||
cmd = cmd + " \"" + purpose_dir + "\""
|
|
||||||
else:
|
|
||||||
cmd = "cd /d \"" + purpose_dir + "\" && git pull && git submodule update"
|
|
||||||
print(cmd)
|
|
||||||
os.system(cmd)
|
|
Loading…
x
Reference in New Issue
Block a user