schon/scripts/Windows/uninstall.ps1
Egor fureunoir Gorbunov c3b4637044 feat(uninstall): enhance volume removal for additional data types
add handling for postgres-data, redis-data, static-data, and media-data volumes in both Windows and Unix uninstall scripts. Ensures errors are logged if volume removal fails.
2026-03-02 00:15:36 +03:00

65 lines
No EOL
1.9 KiB
PowerShell

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# Load shared utilities
$utilsPath = Join-Path $PSScriptRoot '..\lib\utils.ps1'
. $utilsPath
.\scripts\Windows\starter.ps1
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
# Shutdown services
Write-Step "Shutting down..."
docker compose down
if ($LASTEXITCODE -ne 0) {
Write-Error-Custom "Failed to shut down services"
exit $LASTEXITCODE
}
Write-Success "Services were shut down successfully!"
# Remove volumes
Write-Step "Removing volumes..."
docker volume remove -f schon_postgres-data
if ($LASTEXITCODE -ne 0) {
Write-Warning-Custom "Failed to remove postgres-data volume"
}
docker volume remove -f schon_redis-data
if ($LASTEXITCODE -ne 0) {
Write-Warning-Custom "Failed to remove redis-data volume"
}
docker volume remove -f schon_static-data
if ($LASTEXITCODE -ne 0) {
Write-Warning-Custom "Failed to remove static-data volume"
}
docker volume remove -f schon_media-data
if ($LASTEXITCODE -ne 0) {
Write-Warning-Custom "Failed to remove media-data volume"
}
docker volume remove -f schon_prometheus-data
if ($LASTEXITCODE -ne 0) {
Write-Warning-Custom "Failed to remove prometheus-data volume"
}
docker volume remove -f schon_es-data
if ($LASTEXITCODE -ne 0) {
Write-Warning-Custom "Failed to remove es-data volume"
}
Write-Success "Volumes were removed successfully!"
# Cleanup Docker
Write-Step "Cleaning up unused Docker data..."
docker system prune -a -f --volumes
if ($LASTEXITCODE -ne 0) {
Write-Warning-Custom "Docker cleanup had issues, but continuing..."
}
Write-Success "Unused Docker data cleaned successfully!"
# Remove local files
Write-Step "Removing related files..."
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue ./media
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue ./static
Write-Success "Related files removed successfully!"
Write-Result ""
Write-Result "Bye-bye, hope you return later!"