Lightsail-Backup-and-Clean-Up-Shell-Script
Lightsail-Backup-and-Clean-Up-Shell-Script copied to clipboard
Updated script to make it more useful
I have updated your Lightsail Script to make it more flexible.
Feel free to pull in my fork if you like.
Fantastic work. I will merge it soon.
I am testing this script with a few instances and found it does not work well. the jq select part does not do the work.
I'd the same issue. The following jq part doesn't work SnapshotNames=$(aws lightsail get-instance-snapshots | jq '.[] | sort_by(.createdAt) | select(.[0].fromInstanceName == "'${NameOfYourInstance}'") | .[].name') I'm not an expert in jq, hope for a quick correction
I also have the same issue as @vw1234 , SnapshotNames returns blank. I have tried several variations but I cannot targert the snapshots I need.
Please change the line to :
get the names of all snapshots sorted from old to new
SnapshotNames=$(aws lightsail get-instance-snapshots | jq '.instanceSnapshots | sort_by(.createdAt) | .[] | select(.fromInstanceName == "'${NameOfYourInstance}'") | . name') It works well for me.
didn't work for me but after checking with jqplay.org the following version works for me: SnapshotNames=$(aws lightsail get-instance-snapshots | jq '.instanceSnapshots | sort_by(.createdAt) | .[] | select (.fromInstanceName == "'${NameOfYourInstance}'")| .name')
the difference is no blank between "." and 'name'