Add Windows PowerShell restore script
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user