PayrollManagementSystem/scripts/tplus/inspect_sqlserver_backup.ps1

24 lines
845 B
PowerShell

[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$BackupFileName,
[string]$ContainerName = "ys-tplus-sqlserver-dev",
[string]$BackupRoot = "D:\work\app\tplus-sqlserver\backup",
[Parameter(Mandatory = $true)]
[SecureString]$SaPassword
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
. (Join-Path $PSScriptRoot "container_sql.ps1")
$backupPath = Join-Path $BackupRoot $BackupFileName
if (-not (Test-Path -LiteralPath $backupPath)) {
throw "找不到备份文件:$backupPath"
}
$containerPath = "/var/opt/mssql/backup/$BackupFileName"
$sql = "RESTORE VERIFYONLY FROM DISK = N'$($containerPath.Replace("'", "''"))'; RESTORE FILELISTONLY FROM DISK = N'$($containerPath.Replace("'", "''"))';"
Invoke-TPlusContainerSql -ContainerName $ContainerName -Sql $sql -SaPassword $SaPassword