Problem: AWS Lightsail Backup & Restore Failures – Snapshot Creation or Restoration Issues
Problem: AWS Lightsail Backup & Restore Failures – Snapshot Creation or Restoration Issues
Common Error Messages:
# When creating a snapshot
An error occurred (ServiceException) when calling the
CreateInstanceSnapshot operation:
Instance snapshot creation failed due to an internal service error.
# When restoring a snapshot
An error occurred (InvalidInputException) when calling the
CreateInstances operation:
The specified snapshot ID 'WebServer-Snapshot' is invalid.
# When trying to delete a snapshot
An error occurred (AccessDeniedException) when calling the
DeleteInstanceSnapshot operation:
User is not authorized to perform this action.
Issue:
AWS Lightsail backups use instance snapshots, but sometimes creating, restoring, or deleting snapshots fails. This usually happens due to:
- Snapshot Limit Reached – AWS enforces limits on the number of snapshots per instance.
- Invalid Snapshot ID – The snapshot name may be incorrect or the snapshot does not exist.
- Permissions Issue – The AWS IAM user may not have proper permissions.
- Instance Size Conflict – Trying to restore a snapshot to a smaller instance may cause errors.
- AWS Internal Error – A temporary service issue may prevent snapshot creation.
Fix: Verify Snapshot Status and Apply Fixes
# Step 1: List all available snapshots
$ aws lightsail get-instance-snapshots
# Expected Output...
{
"instanceSnapshots": [
{
"name": "WebServer-Snapshot",
"createdAt": "2025-02-10T12:00:00Z",
"state": "available",
"fromInstanceName": "WebServer",
"sizeInGb": 20
}
]
}
# If no snapshots are listed, the snapshot does not exist.
# Check the snapshot name and try again.
# Step 2: Create a new snapshot (if necessary)
$ aws lightsail create-instance-snapshot \
--instance-name "WebServer" \
--instance-snapshot-name "WebServer-Snapshot-New"
# Expected Output...
{
"operations": [
{
"operationType": "CreateInstanceSnapshot",
"status": "Started"
}
]
}
# Step 3: Verify the snapshot status
$ aws lightsail get-instance-snapshots \
--query "instanceSnapshots[].{Name:name, State:state}"
# Expected Output...
[
{
"Name": "WebServer-Snapshot",
"State": "available"
}
]
# If the state is "pending" or "failed," the snapshot
# did not complete successfully.
# Step 3.1: If the snapshot is stuck in "pending," wait and retry
$ aws lightsail create-instance-snapshot \
--instance-name "WebServer" \
--instance-snapshot-name "WebServer-Snapshot-Retry"
# Step 3.2: If the snapshot is "failed," delete and retry
$ aws lightsail delete-instance-snapshot \
--instance-snapshot-name "WebServer-Snapshot"
# Expected Output...
{
"operations": [
{
"operationType": "DeleteInstanceSnapshot",
"status": "Started"
}
]
}
# Step 3.3: Check instance health before retrying snapshot creation
$ aws lightsail get-instance-metric-data \
--instance-name "WebServer" \
--metric-name StatusCheckFailed \
--period 60 \
--statistics Maximum \
--unit Count
# Expected Output...
{
"datapoints": [
{
"timestamp": "2025-02-10T12:00:00Z",
"maximum": 1.0,
"unit": "Count"
}
],
"label": "StatusCheckFailed"
}
# Step 3.4: If the "maximum" value is 1.0 or higher,
# check if it's an AWS issue
$ aws lightsail get-instance-metric-data \
--instance-name "WebServer" \
--metric-name StatusCheckFailed_System \
--period 60 \
--statistics Maximum \
--unit Count
# If StatusCheckFailed_System = 1.0, AWS detected a hardware failure.
# Solution: Create a new instance from a working snapshot instead.
# Step 3.5: If AWS did not detect a system failure, restart and retry
$ aws lightsail reboot-instance \
--instance-name "WebServer"
$ aws lightsail create-instance-snapshot \
--instance-name "WebServer" \
--instance-snapshot-name "WebServer-Snapshot-Retry"
# Step 4: Restore the snapshot to a new instance
$ aws lightsail create-instances \
--instance-names "WebServer-Restored" \
--availability-zone "us-east-1a" \
--blueprint-id "ubuntu_22_04" \
--bundle-id "medium_3_0" \
--source-instance-id "WebServer-Snapshot"
# Expected Output...
{
"operations": [
{
"operationType": "CreateInstancesFromSnapshot",
"status": "Started"
}
]
}
# Step 5: If you hit the snapshot limit, delete old snapshots
$ aws lightsail delete-instance-snapshot \
--instance-snapshot-name "Old-Snapshot"
# Expected Output...
{
"operations": [
{
"operationType": "DeleteInstanceSnapshot",
"status": "Started"
}
]
}
# Step 6: If permissions issues occur, check IAM policies
$ aws lightsail get-instance-access-details \
--instance-name "WebServer"
# Expected Output (If user is unauthorized)...
An error occurred (AccessDeniedException) when calling the
GetInstanceAccessDetails operation:
User is not authorized to perform this action.
# Fix: Ensure the IAM user has the required Lightsail permissions
# Navigate to the AWS IAM console and attach the following policy:
{
"Effect": "Allow",
"Action": [
"lightsail:GetInstanceSnapshots",
"lightsail:CreateInstanceSnapshot",
"lightsail:DeleteInstanceSnapshot",
"lightsail:CreateInstancesFromSnapshot"
],
"Resource": "*"
}
# Step 7: If AWS service issues persist, check AWS status
$ curl -s https://status.aws.amazon.com | grep Lightsail
# If AWS is experiencing service outages, wait and retry later.
# FINAL STEP: Verify that the new instance is running
$ aws lightsail get-instances \
--query "instances[].{Name:name, State:state.name}"
# Expected Output...
[
{
"Name": "WebServer-Restored",
"State": "running"
}
]
Need AWS Expertise?
If you're looking for guidance on Amazon Lightsail or any cloud challenges, feel free to reach out! We'd love to help you tackle your Lightsail projects. 🚀
Email us at: info@pacificw.com
Image: Gemini
Comments
Post a Comment