#!/usr/bin/env bash echo "🔄 Starting automatic LXD snapshot for all running containers..." # Get a list of running container names containers=$(lxc list --format csv -c ns | awk -F, '$2 == "RUNNING" {print $1}') if [[ -z "$containers" ]]; then echo "❌ No running containers found!" exit 1 fi # Create a snapshot for each container timestamp=$(date +%Y%m%d-%H%M%S) for container in $containers; do snapshot_name="auto-${timestamp}" echo "🟡 Creating snapshot for $container: $snapshot_name" lxc snapshot "$container" "$snapshot_name" done echo "✅ Snapshot creation complete!"