commit cbae9a4800e02e4d1d4ccb8fd1f721427c481dcc Author: offends Date: Mon Aug 25 16:04:54 2025 +0800 synchronization diff --git a/.drone-minio.yml b/.drone-minio.yml new file mode 100644 index 0000000..048fdde --- /dev/null +++ b/.drone-minio.yml @@ -0,0 +1,35 @@ +kind: pipeline +type: docker +name: Git Backup + +# 手动触发或接口触发 +trigger: + event: + - custom + +steps: +# 账号密码特殊字符需要使用 URL 编码代替 +- name: Git Clone + image: registry.cn-hangzhou.aliyuncs.com/offends/drone:git + pull: if-not-exists + environment: + GIT_USERNAME: + from_secret: GIT_USERNAME + GIT_PASSWORD: + from_secret: GIT_PASSWORD + commands: + - bash Build.sh $GIT_USERNAME $GIT_PASSWORD + +- name: Backup File To Minio + image: registry.cn-hangzhou.aliyuncs.com/offends/drone:mc + pull: if-not-exists + environment: + MINIO_URl: + from_secret: MINIO_URl + MINIO_ACCESS_KEY: + from_secret: MINIO_ACCESS_KEY + MINIO_SECRET_KEY: + from_secret: MINIO_SECRET_KEY + commands: + - mc config host add minio $MINIO_URl $MINIO_ACCESS_KEY $MINIO_SECRET_KEY + - mc cp ./*.tar.gz minio/backup/ \ No newline at end of file diff --git a/.drone-oss.yml b/.drone-oss.yml new file mode 100644 index 0000000..ba29a1d --- /dev/null +++ b/.drone-oss.yml @@ -0,0 +1,36 @@ +kind: pipeline +type: docker +name: Git Backup + +# 手动触发或接口触发 +trigger: + event: + - custom + +steps: +# 账号密码特殊字符需要使用 URL 编码代替 +- name: Git Clone + image: registry.cn-hangzhou.aliyuncs.com/offends/drone:git + pull: if-not-exists + environment: + GIT_USERNAME: + from_secret: GIT_USERNAME + GIT_PASSWORD: + from_secret: GIT_PASSWORD + commands: + - bash Build.sh $GIT_USERNAME $GIT_PASSWORD + +- name: Backup File To OSS + image: registry.cn-hangzhou.aliyuncs.com/offends/drone:oss + pull: if-not-exists + environment: + OOS_ENDPOINT: + from_secret: OOS_ENDPOINT + OOS_ACCESSKEYID: + from_secret: OOS_ACCESSKEYID + OOS_ACCESSKEYSECRET: + from_secret: OOS_ACCESSKEYSECRET + OOS_PATH: + from_secret: OOS_PATH + commands: + - ossutil64 -e $OOS_ENDPOINT -i $OOS_ACCESSKEYID -k $OOS_ACCESSKEYSECRET cp ./*.tar.gz $OOS_PATH --force \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d4777d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# ---> macOS +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + diff --git a/Build.sh b/Build.sh new file mode 100644 index 0000000..60ed678 --- /dev/null +++ b/Build.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +############################################################################################# +# 用途: Clone 项目 +# 作者: 丁辉 +# 编写时间: 2024-01-18 +############################################################################################# + +# 项目仓库 +IFS=$'\n' + +# 读取文件并存入数组 +GIT_NAME=($(> file.txt +done + +# 打包 +tar -zcvf Git_Backup.tar.gz $(cat file.txt) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9bda76a --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +> 本文作者:丁辉 + +# Drone备份GIT仓库文件到 OSS & Minio + +> Drone 基础镜像 Dockerfile 所在仓库 +> +> [Drone-Images](https://gitee.com/offends/Kubernetes/tree/main/Docker/Dockerfile/Drone-Images) + +> Git 账号密码带有特殊符号时需要按照 URL 编码参考手册替换特殊符号!!! +> +> [URL 编码参考手册](https://www.w3school.com.cn/tags/html_ref_urlencode.asp) +> +> 例如:如果我的 GIT 账号有 "@" 符号, 则需要用 " %40" 代替 + +1. 修改 `repositories.list` 文件内自己需要备份的仓库地址 + +2. 更具需要使用的备份方式修改 Drone Configuration 文件为: + + - `.drone-minio.yml` + - `.drone-oss.yml` + +3. Drone 工具添加 Secrets + + - 备份至OSS + + **添加 Drone Secrets** + + | 参数 | 解释 | 示例 | + | :-----------------: | :--------------------------: | :------------------------: | + | GIT_USERNAME | Git仓库账户 | *** | + | GIT_PASSWORD | Git仓库密码 | *** | + | OOS_ACCESSKEYID | 访问密钥 | *** | + | OOS_ACCESSKEYSECRET | 访问密钥 | *** | + | OOS_ENDPOINT | 设置Bucket所在地域的域名信息 | oss-cn-<地区>.aliyuncs.com | + | OOS_PATH | 配置文件备份 OSS 存储路径 | oss:///<目录> | + + - 备份至 Minio + + **添加 Drone Secrets** + + | 参数 | 解释 | 示例 | + | :--------------: | :---------------: | :------------------------: | + | GIT_USERNAME | Git仓库账户 | *** | + | GIT_PASSWORD | Git仓库密码 | *** | + | MINIO_URl | Minio存储访问地址 | https://<地址>:9000/Bucket | + | MINIO_ACCESS_KEY | 访问密钥 | *** | + | MINIO_SECRET_KEY | 访问密钥 | *** | + +4. 点击 Drone "NEW BUILD" 开始备份 diff --git a/repositories.list b/repositories.list new file mode 100644 index 0000000..257efe9 --- /dev/null +++ b/repositories.list @@ -0,0 +1,7 @@ +https://gitea.offends.cn/offends/Kubernetes.git +https://gitea.offends.cn/offends/Linux.git +https://gitea.offends.cn/offends/System.git +https://gitea.offends.cn/offends/dinghui40.git +https://gitea.offends.cn/offends/Hexo-Async-Offends.git +https://gitea.offends.cn/offends/Git_Backup.git +https://gitea.offends.cn/offends/Rainbond.git \ No newline at end of file