How do I use the AWS CLI to create an automated snapshot in Lightsail?

1 minute read
0

I want to use the AWS Command Line Interface (AWS CLI) to create an automated snapshot in Amazon Lightsail.

Resolution

Note: If you receive errors when you run AWS CLI commands, then see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.

To use the AWS CLI to create an automated snapshot in Lightsail, complete the following steps:

  1. Create a snapshot script:

    #!/bin/bash  
    # Create a snapshot  
    aws lightsail create-instance-snapshot \  
        —instance-name example-instance-name \  
            —createsnapshot.sh  "$INSTANCE_NAME$(date +%Y%m%d%H%M%S)" —example-default-region

    Note: In the preceding command, replace the example- values with your instance name and AWS Region.

  2. Add permissions to run the script:

    $ chmod +x createsnapshot.sh
  3. Schedule the script:

    $ crontab -e  
    0 * * * * /path/to/createsnapshot.sh
  4. Make sure that the script is active:

    ./createsnapshot.sh

    Note: To verify that snapshots are active, open the Lightsail dashboard, and then choose the Snapshots tab.

AWS OFFICIAL
AWS OFFICIALUpdated 4 months ago