diff options
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!" |
