自建Git服务器实现一键重装恢复

git init –bare openclaw-memory.git git init –bare openclaw-skills.git git init –bare openclaw-dotfiles.git git init –bare openclaw-recovery.git

chown -R git:git /srv/git

公钥添加到服务器

cat ~/.ssh/id_rsa.pub >> /home/git/.ssh/authorized_keys

cat > /etc/systemd/system/git-daemon.service << 'EOF' [Unit] Description=Git Daemon After=network.target

[Service] Type=simple ExecStart=/usr/lib/git-core/git-daemon –reuseaddr –base-path=/srv/git –export-all –verbose Restart=always User=git

[Install] WantedBy=multi-user.target EOF

systemctl daemon-reload systemctl enable git-daemon systemctl start git-daemon

2. 部署私钥

mkdir -p ~/.ssh chmod 700 ~/.ssh cp id_rsa ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa

3. 配置SSH跳过host key检查(内网安全)

cat > ~/.ssh/config << 'EOF' Host 10.10.10.230 StrictHostKeyChecking no UserKnownHostsFile /dev/null User git Port 22 IdentityFile ~/.ssh/id_rsa EOF

4. 安装Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

5. 安装Git、Node

brew install git node

6. 克隆所有仓库

git clone git@10.10.10.230:/srv/git/openclaw-dotfiles.git /tmp/dotfiles git clone git@10.10.10.230:/srv/git/openclaw-memory.git ~/.openclaw/workspace git clone git@10.10.10.230:/srv/git/openclaw-skills.git ~/.openclaw/workspace/skills

7. 恢复配置

cp /tmp/dotfiles/.zshrc ~/ cp /tmp/dotfiles/*.pub ~/.ssh/ cd /tmp/dotfiles && brew bundle install

8. 安装OpenClaw

npm install -g openclaw

echo "恢复完成!"

或手动分别备份

cd ~/.openclaw/workspace && git add -A && git commit -m "backup" && git push cd ~/.openclaw/workspace/skills && git add -A && git commit -m "backup" && git push

SSH读写(日常使用)

git@10.10.10.230:/srv/git/openclaw-memory.git git@10.10.10.230:/srv/git/openclaw-skills.git git@10.10.10.230:/srv/git/openclaw-dotfiles.git git@10.10.10.230:/srv/git/openclaw-recovery.git

Built with Hugo
Theme Stack designed by Jimmy