summaryrefslogtreecommitdiff
path: root/lxd_auto_snap.sh
diff options
context:
space:
mode:
authordoc <doc@filenotfound.org>2025-09-16 11:30:38 +0000
committerdoc <doc@filenotfound.org>2025-09-16 11:30:38 +0000
commit5cfeb2cf156705349730bdc6ce883fd8eb22e728 (patch)
tree13758f78513ed74198d2257c11c0ef9a913725d1 /lxd_auto_snap.sh
first commitHEADmaster
Diffstat (limited to 'lxd_auto_snap.sh')
-rwxr-xr-xlxd_auto_snap.sh21
1 files changed, 21 insertions, 0 deletions
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!"