Add Windows CMD restore script
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
:: Restore a git mirror backup into a target repository.
|
||||
:: Works on Windows (CMD).
|
||||
|
||||
if "%~1"=="" (
|
||||
echo Usage: %~nx0 ^<backup.zip^> ^<target-repo-url^>
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "ZIP=%~1"
|
||||
set "TARGET=%~2"
|
||||
set "WORK_DIR=.tmp_restore_mirror"
|
||||
|
||||
if not exist "%ZIP%" (
|
||||
echo Error: file not found: %ZIP%
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [1/3] Extracting %ZIP% ...
|
||||
mkdir "%WORK_DIR%" >nul 2>&1
|
||||
powershell -NoProfile -Command "Expand-Archive -Path '%ZIP%' -DestinationPath '%WORK_DIR%' -Force"
|
||||
|
||||
echo [2/3] Pushing all refs to %TARGET% ...
|
||||
pushd "%WORK_DIR%"
|
||||
git remote set-url origin "%TARGET%"
|
||||
git push --mirror
|
||||
popd
|
||||
|
||||
echo [3/3] Done. Repository restored at %TARGET%
|
||||
|
||||
rmdir /s /q "%WORK_DIR%" >nul 2>&1
|
||||
Reference in New Issue
Block a user