Files
git-mirror-zip/git-restore-zip-macos.sh
T
2026-08-05 21:31:21 +03:00

33 lines
611 B
Bash

# Restore a git mirror backup into a target repository.
# Works on macOS.
set -euo pipefail
if [ $# -lt 2 ]; then
echo "Usage: $0 <backup.zip> <target-repo-url>"
exit 1
fi
ZIP="$1"
TARGET="$2"
WORK_DIR=".tmp_restore_mirror"
if [ ! -f "$ZIP" ]; then
echo "Error: file not found: $ZIP"
exit 1
fi
cleanup() { rm -rf "$WORK_DIR"; }
trap cleanup EXIT
echo "[1/3] Extracting $ZIP ..."
mkdir -p "$WORK_DIR"
unzip -q "$ZIP" -d "$WORK_DIR"
echo "[2/3] Pushing all refs to $TARGET ..."
cd "$WORK_DIR"
git remote set-url origin "$TARGET"
git push --mirror
echo "[3/3] Done. Repository restored at $TARGET"