File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1212# Variables
1313# Put your API key here
1414api_key=" YOUR_API_KEY_HERE"
15+ # Vultr API
16+ API=" https://api.vultr.com/v1"
1517# We keep the total number of snapshots under 11 based on two virtual private servers (VPS)
1618snapshot_limit=" 8"
1719
1820# Query all VPS SUBIDs
19- VPS_names=$( curl -s " https://api.vultr.com/v1 /server/list?api_key=$api_key " | jq -r ' keys | ' .[]' ' )
21+ VPS_names=$( curl -s " $API /server/list?api_key=$api_key " | jq -r ' keys | ' .[]' ' )
2022# Query all snapshots and count them
21- snapshot_count=$( curl -s " https://api.vultr.com/v1 /snapshot/list?api_key=$api_key " | jq -r ' keys | .[]' | wc -l | awk ' { print $1 }' )
23+ snapshot_count=$( curl -s " $API /snapshot/list?api_key=$api_key " | jq -r ' keys | .[]' | wc -l | awk ' { print $1 }' )
2224# Query oldest snapshot created
23- last_snapshot_ID=$( curl -s " https://api.vultr.com/v1 /snapshot/list?api_key=$api_key " | jq -r ' keys_unsorted | .[]' | tail -1)
25+ last_snapshot_ID=$( curl -s " $API /snapshot/list?api_key=$api_key " | jq -r ' keys_unsorted | .[]' | tail -1)
2426
2527# Delete the oldest snapshots until the $snapshot_limit is reached
2628until [ " $snapshot_count " -eq " $snapshot_limit " ]; do
3436
3537# Creating a snapshot for every existing VPS
3638for vps in $VPS_names ; do
37- VPS_label=$( curl -s " https://api.vultr.com/v1 /server/list?api_key=$api_key &SUBID=$vps " | jq -r ' .label' )
39+ VPS_label=$( curl -s " $API /server/list?api_key=$api_key &SUBID=$vps " | jq -r ' .label' )
3840 if curl -s " https://api.vultr.com/v1/snapshot/create?api_key=$api_key " --data SUBID=$vps --data description=$VPS_label | grep -q ' SNAPSHOTID' ; then
3941 logger " [OK - Backup] Creating a snapshot for VPS on Vultr: '$VPS_label ' with SUBID: '$vps '"
4042 else
You can’t perform that action at this time.
0 commit comments