• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

AWS LightSail Create Snapshots

August 8, 2019

Here’s my script to create snapshots of a LightSail instance. Create daily or weekly snapshots.

#!/bin/bash
if [ $1 != '' ]; then 
  prefix=$1
  timestamp=$(date +%s)
  snapshotname=$prefix'_web-server_'$timestamp
  /usr/local/bin/aws lightsail create-instance-snapshot \
  --instance-snapshot-name $snapshotname \
  --instance-name web-server
else
  echo 'Need one argument. e.g. daily or weekly'
fi

#!/bin/bash if [ $1 != '' ]; then prefix=$1 timestamp=$(date +%s) snapshotname=$prefix'_web-server_'$timestamp /usr/local/bin/aws lightsail create-instance-snapshot \ --instance-snapshot-name $snapshotname \ --instance-name web-server else echo 'Need one argument. e.g. daily or weekly' fi

Crontab. Job can be scheduled daily or weekly.

# run daily at 4am
0 4 * * * /bin/bash /root/snapshots/create-snapshot.sh daily 2>&1
# run weekly every sunday at 5am
0 5 * * 0 /bin/bash /root/snapshots/create-snapshot.sh weekly 2>&1

# run daily at 4am 0 4 * * * /bin/bash /root/snapshots/create-snapshot.sh daily 2>&1 # run weekly every sunday at 5am 0 5 * * 0 /bin/bash /root/snapshots/create-snapshot.sh weekly 2>&1

Filed Under: Cloud Tagged With: aws, cli, create, cron, lightsail, snapshots

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023