scripts/restore-db.ps1 (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
param(
[Parameter(Mandatory = $true)]
[string]$Backup
)
$Root = Split-Path -Parent $PSScriptRoot
$Db = Join-Path $Root "data\snow.db"
$BackupDir = Join-Path $Root "data\backups"
$Source = $Backup
if (-not (Test-Path $Source)) {
$Source = Join-Path $BackupDir $Backup
}
if (-not (Test-Path $Source)) {
Write-Error "Backup not found: $Source"
exit 1
}
Write-Host "This will overwrite $Db with:"
Write-Host " $Source"
Write-Host "Stop the backend first: docker compose stop backend"
$Confirm = Read-Host "Type RESTORE to continue"
if ($Confirm -ne "RESTORE") {
Write-Host "Aborted."
exit 0
}
New-Item -ItemType Directory -Force -Path (Split-Path $Db) | Out-Null
Copy-Item $Source $Db -Force
Write-Host "Database restored from $Source"
|