From 5cfeb2cf156705349730bdc6ce883fd8eb22e728 Mon Sep 17 00:00:00 2001 From: doc Date: Tue, 16 Sep 2025 11:30:38 +0000 Subject: first commit --- lxd_auto_snap.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lxd_auto_snap.sh (limited to 'lxd_auto_snap.sh') diff --git a/lxd_auto_snap.sh b/lxd_auto_snap.sh new file mode 100755 index 0000000..fa87eaa --- /dev/null +++ b/lxd_auto_snap.sh @@ -0,0 +1,21 @@ +#!/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!" -- cgit v1.2.3