diff options
| author | doc <doc@filenotfound.org> | 2025-09-16 11:30:38 +0000 |
|---|---|---|
| committer | doc <doc@filenotfound.org> | 2025-09-16 11:30:38 +0000 |
| commit | 5cfeb2cf156705349730bdc6ce883fd8eb22e728 (patch) | |
| tree | 13758f78513ed74198d2257c11c0ef9a913725d1 /lxd_auto_snap.sh | |
Diffstat (limited to 'lxd_auto_snap.sh')
| -rwxr-xr-x | lxd_auto_snap.sh | 21 |
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!" |
