AWS CLI 명령을 사용하여 Lightsail 인스턴스에 대한 스냅샷을 관리하고 백업을 생성하려면 어떻게 해야 하나요?
AWS 명령줄 인터페이스(AWS CLI) 명령을 사용하여 Amazon Lightsail 인스턴스에 대한 스냅샷을 관리하고 백업을 생성하려고 합니다. 어떻게 해야 하나요?
간략한 설명
Amazon Lightsail AWS CLI 명령 목록은 AWS CLI 명령 참조 및 Amazon Lightsail API 참조를 참조하세요.
다음은 Lightsail 인스턴스에서 AWS CLI 명령을 사용하여 스냅샷 및 백업을 관리하는 시나리오입니다.
- 수동 백업 관리
인스턴스에 대한 수동 백업을 생성합니다.
사용 가능한 스냅샷을 나열합니다. - 자동 스냅샷 관리
인스턴스에서 자동 스냅샷이 활성화되어 있는지 확인합니다.
자동 스냅샷을 활성화합니다.
자동 스냅샷을 나열하고 더 큰 번들 크기 또는 더 상위 Lightsail 플랜에 해당하는 백업에서 새 인스턴스를 생성할 수 있습니다.
중요: AWS CLI 명령을 사용할 때는 다음 사항에 유의하세요.
- AWS CLI 명령을 실행할 때 오류가 발생하는 경우 최신 버전의 AWS CLI를 사용하고 있는지 확인하세요.
- JSON은 기본 AWS CLI 출력입니다. 기본값을 사용하거나 명령에 --output json을 추가하여 다음 예제와 같이 출력을 수신할 수 있습니다. 자세한 내용은 AWS CLI의 명령 출력 제어를 참조하세요.
- AWS CLI 오류 해결에 대한 일반적인 내용은 AWS CLI 명령을 실행할 때 오류가 발생하는 이유는 무엇입니까?를 참조하세요.
- AWS CLI 출력은 Unix Epoch 시간으로 타임스탬프를 표시합니다. 다음 방법 중 하나를 사용하여 타임스탬프를 UTC로 변환합니다.
macOS
타임스탬프에서 소수점과 소수점 오른쪽에 있는 모든 숫자를 제거한 후 다음 명령을 실행합니다.
# date -r 1602175741 -u Thu Oct 8 16:49:01 UTC 2020
Linux
다음 명령을 실행합니다.
# date -d @1602175741.603 -u Thu Oct 8 16:49:01 UTC 2020
Windows
epochconverter.com과 같은 변환기를 사용하여 타임스탬프를 변환합니다.
해결 방법
수동 백업 관리
Lightsail 인스턴스에 대한 수동 백업 만들기
create-instance-snapshot 명령을 실행하여 Lightsail 인스턴스의 스냅샷을 생성합니다.
eu-west-1 리전에서 SnapshotTestLightsailInstance1 스냅샷을 생성합니다. --instance-snapshot-name, --instance-name, --region을 요청에 적합한 값으로 바꿉니다.
# aws lightsail create-instance-snapshot --instance-name TestLightsailInstance1 --instance-snapshot-name SnapshotTestLightsailInstance1 { "operations": [ { "id": "d3196be7-3dc6-4508-b335-16ce45f11c90", "resourceName": "SnapshotTestLightsailInstance1", "resourceType": "InstanceSnapshot", "createdAt": 1602180831.638, "location": { "availabilityZone": "all", "regionName": "eu-west-1" }, "isTerminal": false, "operationDetails": "TestLightsailInstance1", "operationType": "CreateInstanceSnapshot", "status": "Started", "statusChangedAt": 1602180831.638 }, { "id": "df237a33-bca9-4fc3-8f46-ea5d12606f5c", "resourceName": "TestLightsailInstance1", "resourceType": "Instance", "createdAt": 1602180831.638, "location": { "availabilityZone": "eu-west-1a", "regionName": "eu-west-1" }, "isTerminal": false, "operationDetails": "SnapshotTestLightsailInstance1", "operationType": "CreateInstanceSnapshot", "status": "Started", "statusChangedAt": 1602180831.638 } ] }
사용 가능한 스냅샷 나열
get-instance-snapshots 명령을 실행하여 Lightsail 인스턴스에 대한 모든 스냅샷을 나열합니다. 다음 예시에서는 eu-west-1에서 사용할 수 있는 스냅샷에 대한 세부 정보를 보여 줍니다. --region을 요청에 적합한 값으로 바꿉니다.
# aws lightsail get-instance-snapshots --region eu-west-1 --query 'instanceSnapshots[].{name:name,createdAt:createdAt,resourceType:resourceType,state:state,fromInstanceName:fromInstanceName,sizeInGb:sizeInGb}' --output table ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | GetInstanceSnapshots | +----------------+-----------------------------------------+------------------------------------------------------------------------------------------------------------+-------------------+-----------+-------------+ | createdAt | fromInstanceName | name | resourceType | sizeInGb | state | +----------------+-----------------------------------------+------------------------------------------------------------------------------------------------------------+-------------------+-----------+-------------+ | 1602180831.638| TestLightsailInstance1 | SnapshotTestLightsailInstance1 | InstanceSnapshot | 40 | available | +----------------+-----------------------------------------+------------------------------------------------------------------------------------------------------------+-------------------+-----------+-------------+
자동 스냅샷 관리
인스턴스에서 자동 스냅샷이 활성화되어 있는지 확인
다음 명령을 실행하여 인스턴스에 자동 스냅샷이 활성화되어 있는지 확인하고 정의된 일정을 표시합니다. TestLightsailInstance1을 사용자의 인스턴스 이름으로 바꾸고 --region을 해당하는 리전으로 수정합니다.
# aws lightsail get-instances --region eu-west-1 --query 'instances[].{addOns:addOns,name:name,publicIpAddress:publicIpAddress,AutoMatciSnapshotStatus:(addOns[].status),Schedule:(addOns[].snapshotTimeOfDay)}' --output text| grep -w "TestLightsailInstance1" ['Enabled'] ['20:00'] [{'name': 'AutoSnapshot', 'status': 'Enabled', 'snapshotTimeOfDay': '20:00'}] TestLightsailInstance1 3.250.xx.xx
자동 스냅샷 활성화
enable-add-on 명령을 실행하여 Lightsail 인스턴스에 대한 자동 스냅샷을 활성화합니다. 다음 예시에서는 UTC(08PM UTC) 기준 1시간 간격으로 설정된 일일 자동 스냅샷을 생성합니다. --resource-name, snapshotTimeOfDay, --region을 요청에 적합한 값으로 바꿉니다.
# aws lightsail enable-add-on --region eu-west-1 --resource-name TestLightsailInstance1 --add-on-request addOnType=AutoSnapshot,autoSnapshotAddOnRequest={snapshotTimeOfDay=20:00} { "operations": [ { "id": "823bb162-9848-4897-b845-8f41c375801a", "resourceName": "TestLightsailInstance1", "resourceType": "Instance", "createdAt": 1602181856.652, "location": { "availabilityZone": "eu-west-1", "regionName": "eu-west-1" }, "isTerminal": false, "operationDetails": "EnableAddOn - AutoSnapshot", "operationType": "EnableAddOn", "status": "Started" } ] }
자동 스냅샷 나열 및 백업에서 더 큰 번들 크기 또는 상위 Lightsail 플랜을 갖춘 새 인스턴스 만들기
- get-auto-snapshots 명령을 실행하여 Lightsail 인스턴스 또는 디스크에 대하여 사용 가능한 모든 자동 스냅샷을 나열합니다. 다음 예시에서는 TestLightsailInstance1 인스턴스에 대하여 사용할 수 있는 스냅샷의 세부 정보를 보여 줍니다. --resource-name 및 --region을 요청에 적절한 값으로 바꿉니다.
# aws lightsail get-auto-snapshots --region eu-west-1 --resource-name TestLightsailInstance1 { "resourceName": "TestLightsailInstance1", "resourceType": "Instance", "autoSnapshots": [ { "date": "2020-10-08", "createdAt": 1602188663.0, "status": "Success", "fromAttachedDisks": [] } ] }
- create-instances-from-snapshot 명령을 실행하여 수동 또는 자동 백업에서 1개 이상의 Lightsail 인스턴스를 만듭니다. 다음 예시에서는 특정 백업과 더 큰 크기의 번들을 사용하여 eu-west-1 리전에서 인스턴스를 만듭니다. --instance-snapshot-name, --instance-names, bundle-id, --region를 요청에 적합한 값으로 바꿉니다.
# aws lightsail create-instances-from-snapshot --region eu-west-1 --instance-snapshot-name SnapshotTestLightsailInstance1 --instance-names RestoredTestLightsailInstance1-New --availability-zone eu-west-1a --bundle-id large_2_0 { "operations": [ { "id": "09f7d1bb-90f4-48dc-b304-543499e11208", "resourceName": "RestoredTestLightsailInstance1-New", "resourceType": "Instance", "createdAt": 1602182374.625, "location": { "availabilityZone": "eu-west-1a", "regionName": "eu-west-1" }, "isTerminal": false, "operationType": "CreateInstancesFromSnapshot", "status": "Started", "statusChangedAt": 1602182374.625 } ] }
다음 예시에서는 지정된 백업과 더 큰 크기의 번들을 기반으로 새 인스턴스를 만듭니다.
# aws lightsail get-instances --region eu-west-1 --query 'instances[].{name:name,createdAt:createdAt,blueprintId:blueprintId,blueprintName:blueprintName,publicIpAddress:publicIpAddress}' --output table |grep -i RestoredTestLightsailInstance1-New | wordpress | WordPress | 1602182374.625 | RestoredTestLightsailInstance1-New | 34.247.xx.xx |
관련 정보
AWS CLI 명령을 사용하여 Lightsail 인스턴스를 관리하려면 어떻게 해야 하나요?
AWS CLI 명령을 사용하여 Lightsail 인스턴스에서 고정 IP 주소를 관리하려면 어떻게 해야 하나요?

관련 콘텐츠
- 질문됨 2달 전lg...
- 질문됨 2달 전lg...
- 질문됨 2달 전lg...
- 질문됨 15일 전lg...
- 질문됨 4달 전lg...
- AWS 공식업데이트됨 2년 전
- AWS 공식업데이트됨 2년 전
- AWS 공식업데이트됨 8달 전
- AWS 공식업데이트됨 3년 전