Add Windows PowerShell restore script

This commit is contained in:
2026-08-05 21:31:27 +03:00
parent 01bf477860
commit d978491bfc
+34
View File
@@ -0,0 +1,34 @@
param(
[Parameter(Mandatory = $true, Position = 0)]
[string]$Zip,
[Parameter(Mandatory = $true, Position = 1)]
[string]$Target
)
$ErrorActionPreference = "Stop"
$WorkDir = ".tmp_restore_mirror"
if (-not (Test-Path $Zip)) {
Write-Host "Error: file not found: $Zip"
exit 1
}
try {
Write-Host "[1/3] Extracting $Zip ..."
New-Item -ItemType Directory -Force -Path $WorkDir | Out-Null
Expand-Archive -Path $Zip -DestinationPath $WorkDir -Force
Write-Host "[2/3] Pushing all refs to $Target ..."
Push-Location $WorkDir
git remote set-url origin $Target
git push --mirror
Pop-Location
Write-Host "[3/3] Done. Repository restored at $Target"
}
finally {
if (Test-Path $WorkDir) {
Remove-Item -Recurse -Force $WorkDir
}
}