all repos — snow-editor @ 65993a713586363acceab129af67161a5fbe71cc

small and cozy markdown, and orgmode editor

scripts/backup-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
$Root = Split-Path -Parent $PSScriptRoot
$Db = Join-Path $Root "data\snow.db"
$BackupDir = Join-Path $Root "data\backups"

if (-not (Test-Path $Db)) {
    Write-Error "Database not found: $Db"
    exit 1
}

New-Item -ItemType Directory -Force -Path $BackupDir | Out-Null
$Stamp = Get-Date -Format "yyyy-MM-dd-HHmmss"
$Dest = Join-Path $BackupDir "snow-$Stamp.db"

$sqlite3 = Get-Command sqlite3 -ErrorAction SilentlyContinue
if ($sqlite3) {
    & sqlite3 $Db ".backup '$Dest'"
} else {
    Write-Host "sqlite3 not found — copying file (stop the backend first for a safe copy)."
    Copy-Item $Db $Dest
}

Write-Host "Backup saved: $Dest"