synchronization
This commit is contained in:
35
.drone-minio.yml
Normal file
35
.drone-minio.yml
Normal file
@@ -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/
|
36
.drone-oss.yml
Normal file
36
.drone-oss.yml
Normal file
@@ -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
|
28
.gitignore
vendored
Normal file
28
.gitignore
vendored
Normal file
@@ -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
|
27
Build.sh
Normal file
27
Build.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
#############################################################################################
|
||||
# 用途: Clone 项目
|
||||
# 作者: 丁辉
|
||||
# 编写时间: 2024-01-18
|
||||
#############################################################################################
|
||||
|
||||
# 项目仓库
|
||||
IFS=$'\n'
|
||||
|
||||
# 读取文件并存入数组
|
||||
GIT_NAME=($(<repositories.list))
|
||||
|
||||
# 恢复默认的分隔符
|
||||
unset IFS
|
||||
|
||||
for i in "${GIT_NAME[@]}"; do
|
||||
GIT_URL=$(echo $i | awk -F '//' '{print $2}')
|
||||
git clone -b main --depth=1 https://$1:$2@$GIT_URL
|
||||
GIT_FILE=$(echo $i | sed 's/\.git$//' | grep -oE '[^/]+$')
|
||||
rm -rf $GIT_FILE/.git
|
||||
echo $GIT_FILE >> file.txt
|
||||
done
|
||||
|
||||
# 打包
|
||||
tar -zcvf Git_Backup.tar.gz $(cat file.txt)
|
49
README.md
Normal file
49
README.md
Normal file
@@ -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://<Bucket>/<目录> |
|
||||
|
||||
- 备份至 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" 开始备份
|
7
repositories.list
Normal file
7
repositories.list
Normal file
@@ -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
|
Reference in New Issue
Block a user