Created
July 3, 2023 16:32
-
-
Save Alex-Yates/f9a9d6aea7481d2defbf667b0f6fec02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$testMode = $true # By default, don't actually delete anything. Just print out the commands you would execute without executing them. Set this to false if you want to actually delete stuff | |
$images = (rgclone get di --output json) | ConvertFrom-Json | |
$failedImageIds = ($images | Where-Object {$_.status -like "Failed"}).Id | |
$containers = (rgclone get dc --output json) | ConvertFrom-Json | |
$failedContainerIds = ($containers | Where-Object {$_.status -like "Failed"}).Id | |
if ($failedImageIds.length -ne 0){ | |
$failedImageIds | ForEach-Object { | |
Write-Output "Deleting data-image $_" | |
if ($testMode){ | |
Write-output "NOT ACTUALLY EXECUTING: rgclone delete di $_" | |
} | |
else { | |
& rgclone delete di $_ | |
} | |
} | |
} | |
if ($failedContainerIds.length -ne 0){ | |
$failedContainerIds | ForEach-Object { | |
Write-Output "Deleting data-container $_" | |
if ($testMode){ | |
Write-output "NOT ACTUALLY EXECUTING: rgclone delete dc $_" | |
} | |
else { | |
& rgclone delete di $_ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment