23 lines
1.4 KiB
PowerShell
23 lines
1.4 KiB
PowerShell
|
|
#requires -Version 7.2
|
||
|
|
[CmdletBinding()]
|
||
|
|
param(
|
||
|
|
[Parameter(Mandatory)][string]$MySqlDump,
|
||
|
|
[Parameter(Mandatory)][string]$Output,
|
||
|
|
[switch]$ConfirmSourceStopped
|
||
|
|
)
|
||
|
|
$ErrorActionPreference='Stop'
|
||
|
|
$repo=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../..'))
|
||
|
|
if(-not $ConfirmSourceStopped){throw 'Stop physical acquisition/motion and the source backend first, then pass -ConfirmSourceStopped'}
|
||
|
|
$changes=& git -C $repo status --porcelain
|
||
|
|
if($LASTEXITCODE -ne 0 -or $changes){throw 'Commit and push all source changes before the final data export'}
|
||
|
|
$env:PYTHONDONTWRITEBYTECODE='1'
|
||
|
|
& python (Join-Path $repo 'scripts/migrate_standalone.py') export --mysqldump $MySqlDump --source-runtime (Join-Path $repo '.local/runtime.json') --artifacts (Join-Path $repo '.local/artifacts') --output $Output --confirm-source-stopped
|
||
|
|
if($LASTEXITCODE -ne 0){throw 'Source export failed; do not deliver the incomplete directory'}
|
||
|
|
& python (Join-Path $repo 'scripts/migrate_standalone.py') verify --package $Output
|
||
|
|
if($LASTEXITCODE -ne 0){throw 'Source package verification failed'}
|
||
|
|
$manifest=Join-Path $Output 'manifest.json'
|
||
|
|
$checksum=(Get-FileHash -LiteralPath $manifest -Algorithm SHA256).Hash
|
||
|
|
Write-Output "Final package ready: $Output"
|
||
|
|
Write-Output "manifest.json SHA256: $checksum"
|
||
|
|
Write-Output 'This package contains SQL, business files and private connection/certificate material. Transfer through restricted storage; never add it to Git.'
|