초기 관제 시스템 뼈대 구성
This commit is contained in:
24
scripts/backup-runtime-data.ps1
Normal file
24
scripts/backup-runtime-data.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
param(
|
||||
[string]$DataDir = "runtime-data",
|
||||
[string]$BackupDir = "backups"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$root = (Resolve-Path ".").Path
|
||||
$resolvedDataDir = Resolve-Path $DataDir
|
||||
|
||||
if (-not $resolvedDataDir.Path.StartsWith($root)) {
|
||||
throw "Refusing to back up a path outside the repository: $($resolvedDataDir.Path)"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Path $BackupDir -Force | Out-Null
|
||||
|
||||
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||
$archivePath = Join-Path $BackupDir "cargoradar-runtime-$timestamp.zip"
|
||||
|
||||
Compress-Archive -Path (Join-Path $resolvedDataDir.Path "*") -DestinationPath $archivePath -Force
|
||||
|
||||
[pscustomobject]@{
|
||||
Backup = (Resolve-Path $archivePath).Path
|
||||
} | Format-List
|
||||
Reference in New Issue
Block a user