feat(lxc): auto-remove snapshots during cleanup

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-01-25 13:33:00 -03:00
parent 4e7db823ea
commit e4a55d533a

View file

@ -43,6 +43,16 @@ echo -e "\n[ LXC CONTAINERS CLEANUP ]"
# Check if LXC is installed
if command -v lxc >/dev/null 2>&1; then
# Remove all snapshots from all containers
echo "Removing all LXC snapshots..."
for container in $(lxc list -c n --format csv | grep -v "^$"); do
snapshots=$(lxc list "$container" -c n --format csv -f snapshot)
if [ -n "$snapshots" ]; then
echo "Removing snapshots from container: $container"
lxc snapshot delete "$container" --all
fi
done
for container in $(lxc list -c n --format csv | grep -v "^$"); do
echo -e "\nCleaning container: $container"