Add macOS restore script
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
# 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"
|
||||||
Reference in New Issue
Block a user