From a8cd1c324c0541b0d26542168aeced085ec13201 Mon Sep 17 00:00:00 2001 From: doc Date: Mon, 30 Jun 2025 20:14:17 +0000 Subject: initial failzero commit --- vps/functions/enable_backups_by_label.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 vps/functions/enable_backups_by_label.sh (limited to 'vps/functions/enable_backups_by_label.sh') diff --git a/vps/functions/enable_backups_by_label.sh b/vps/functions/enable_backups_by_label.sh new file mode 100755 index 0000000..08fb31d --- /dev/null +++ b/vps/functions/enable_backups_by_label.sh @@ -0,0 +1,23 @@ +enable_backups_by_label() { + LABEL="$1" + LINODE_ID=$(curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" \ + https://api.linode.com/v4/linode/instances | \ + jq -r --arg LABEL "$LABEL" '.data[] | select(.label == $LABEL) | .id') + + if [ -z "$LINODE_ID" ]; then + echo "❌ No Linode found with label '$LABEL'" + exit 1 + fi + + echo "Enabling backups for Linode '$LABEL' (ID: $LINODE_ID)..." + + HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ + https://api.linode.com/v4/linode/instances/$LINODE_ID/backups/enable \ + -H "Authorization: Bearer $LINODE_API_TOKEN") + + if [[ "$HTTP_STATUS" == "200" ]]; then + echo "✅ Backups enabled for Linode $LABEL." + else + echo "❌ Failed to enable backups (HTTP $HTTP_STATUS)" + fi +} -- cgit v1.2.3