This website requires JavaScript.
0
Issues
Pull Requests
Milestones
Explore
0
Create…
New Repository
New Migration
New Organization
admin
Signed in as
admin
Profile
Starred
Subscriptions
Settings
Help
Site Administration
Sign Out
admin
/
homelab
Watching
1
Participating and mentions
Receive notifications from this repository when participating or mentioned.
All activity
Receive notifications for all events.
Ignore
Never receive notifications from this repository.
Custom
Select events you want to be notified of, in addition to participating and mentions.
Star
0
Fork
0
Notifications
Issues
Pull Requests
Releases
Cancel
Confirm
Code
Issues
Pull Requests
Actions
Packages
Projects
Releases
Wiki
Activity
Settings
Files
homelab
/
scripts
/
or
Cancel
Edit File
Preview
Preview Changes
Spaces
Tabs
2
4
8
Wrap
No wrap
#!/usr/bin/env bash # ============================================================================== # sync-git-to-nas.sh — 将 Mac mini 上的 Gitea 热层数据与大文件同步归档至极空间 Z4 20TB NAS # ============================================================================== set -euo pipefail HOT_DIR="/Users/ixvii0iv/homelab/stacks/git/data" COLD_DIR="/Users/ixvii0iv/nas/个人空间/Git_Cold_Storage" if [ ! -d "/Users/ixvii0iv/nas/个人空间" ]; then echo "[$(date '+%Y-%m-%d %H:%M:%S')] WARN: 极空间 NAS 未挂载,跳过冷存储同步" exit 0 fi mkdir -p "$COLD_DIR/lfs" "$COLD_DIR/attachments" "$COLD_DIR/packages" "$COLD_DIR/repo-archive" "$COLD_DIR/bundles" "$COLD_DIR/db" # 1. 增量同步 LFS 大文件、Release 附件、制品包与归档 rsync -a "$HOT_DIR/lfs/" "$COLD_DIR/lfs/" rsync -a "$HOT_DIR/attachments/" "$COLD_DIR/attachments/" rsync -a "$HOT_DIR/packages/" "$COLD_DIR/packages/" rsync -a "$HOT_DIR/repo-archive/" "$COLD_DIR/repo-archive/" # 2. 将所有 Git 裸仓库打包为独立自包含的 .bundle 冷备文件(任何时候可直接 git clone 恢复) if [ -d "$HOT_DIR/repositories" ]; then find "$HOT_DIR/repositories" -maxdepth 2 -type d -name "*.git" | while read -r repo; do rel_name=$(echo "${repo#$HOT_DIR/repositories/}" | tr '/' '_') /usr/bin/git -C "$repo" bundle create "$COLD_DIR/bundles/${rel_name%.git}.bundle" --all >/dev/null 2>&1 || true done fi # 3. 备份 Gitea SQLite 元数据快照 if [ -f "$HOT_DIR/gitea.db" ]; then /usr/bin/sqlite3 "$HOT_DIR/gitea.db" ".backup '$COLD_DIR/db/gitea-latest.db'" 2>/dev/null || cp "$HOT_DIR/gitea.db" "$COLD_DIR/db/gitea-latest.db" fi echo "[$(date '+%Y-%m-%d %H:%M:%S')] OK: Git 热层仓库与 LFS 大文件已同步归档至极空间 ($COLD_DIR)"
Commit Changes
Add a Signed-off-by trailer by the committer at the end of the commit log message.
Commit directly to the
main
branch.
Create a
new branch
for this commit and start a pull request.
Commit Changes
Cancel