51 lines
1.4 KiB
PowerShell
51 lines
1.4 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Removes stack data: volumes and orphans, optionally build artifacts.
|
|
|
|
.DESCRIPTION
|
|
DANGER: this deletes the TimescaleDB data volume (all telemetry data),
|
|
the MQTT log volume, and the Loki volume. Users/groups/sessions stored
|
|
in Postgres are deleted with it.
|
|
|
|
-Volumes remove the named volumes (data loss!)
|
|
-All additionally remove images and build cache
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[switch]$Volumes,
|
|
[switch]$All
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$StackRoot = Split-Path -Parent $PSScriptRoot
|
|
Set-Location $StackRoot
|
|
|
|
if ($Volumes) {
|
|
Write-Warning "This deletes ALL stored data (telemetry, users, groups, sessions, logs)."
|
|
$confirm = Read-Host "Type 'delete' to continue"
|
|
if ($confirm -ne "delete") {
|
|
Write-Host "Aborted."
|
|
exit 0
|
|
}
|
|
}
|
|
|
|
Write-Host "Removing stack containers..." -ForegroundColor Cyan
|
|
docker compose down --remove-orphans
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
|
|
if ($Volumes) {
|
|
Write-Host "Removing volumes..." -ForegroundColor Cyan
|
|
docker compose down --volumes
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
}
|
|
|
|
if ($All) {
|
|
Write-Host "Removing images and build cache..." -ForegroundColor Cyan
|
|
docker compose down --rmi all
|
|
docker image prune -f
|
|
docker builder prune -f
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
}
|
|
|
|
Write-Host "Done." -ForegroundColor Green |