How do I restore an Amazon EFS file system from an AWS Backup recovery point using the AWS CLI?

Last updated: 2020-03-27

I want to use the AWS Command Line Interface (AWS CLI) to restore an Amazon Elastic File System (Amazon EFS) from an AWS Backup recovery point. How can I do that?

Resolution

In-place restore of an EFS file system from an AWS Backup recovery point

1.    Run the list-backup-jobs command to get the Amazon Resource Name (ARN) of the EFS file system to be restored. You must have the resource ARN to perform an EFS file system restore from an AWS Backup recovery point.

$ aws backup list-backup-jobs --by-resource-type EFS --region us-east-1

2.    In the command output, note the ResourceArn:

{
    "BackupJobs": [
        {
            "CompletionDate": 1584448353.589, 
            "BackupVaultArn": "arn:aws:backup:us-east-1:111222333444:backup-vault:Default", 
            "PercentDone": "0.0", 
            "RecoveryPointArn": "arn:aws:backup:us-east-1:111222333444:recovery-point:f29fe56c-8f44-4877-9ae6-9c6d5dce8935", 
            "ResourceType": "EFS", 
            "BackupSizeInBytes": 73, 
            "State": "COMPLETED", 
            "IamRoleArn": "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole", 
            "ResourceArn": "arn:aws:elasticfilesystem:us-east-1:111222333444:file-system/fs-c1234567", 
            "BackupJobId": "12ddf0b1-aed4-44ec-894f-0d74448949bd", 
            "StartBy": 1584451934.889, 
            "CreationDate": 1584448334.889, 
            "BackupVaultName": "Default"
        }, 
        {
            "CompletionDate": 1583305453.7, 
            "BackupVaultArn": "arn:aws:backup:us-east-1:111222333444:backup-vault:Default", 
            "PercentDone": "0.0", 
            "RecoveryPointArn": "arn:aws:backup:us-east-1:111222333444:recovery-point:09e9dafe-44a6-471a-b4e8-64c98219a480", 
            "ResourceType": "EFS", 
            "BackupSizeInBytes": 73, 
            "State": "COMPLETED", 
            "IamRoleArn": "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole", 
            "ResourceArn": "arn:aws:elasticfilesystem:us-east-1:111222333444:file-system/fs-gd1b761d", 
            "BackupJobId": "721ba96d-a656-4771-a1f4-78bcd0c930f8", 
            "StartBy": 1583309035.684, 
            "CreationDate": 1583305435.684, 
            "BackupVaultName": "Default"
        }
    ]
}

3.    To run the start-restore-job command, you must define specific metadata to restore an EFS instance. You can define the metadata in a separate JSON file, or you can define the metadata as parameters within the command.

To define the metadata in a separate JSON file, create a JSON file similar to the following:

{"file-system-id": "fs-c1234567", "newFileSystem": "false", "Encrypted": "false", "PerformanceMode":"generalPurpose"}

Then, run the start-restore-job command:

aws backup start-restore-job --region us-east-1 --recovery-point-arn "arn:aws:backup:us-east-1:111222333444:recovery-point:123e4567-6cd9-464e-bb6b-13f70e79d347" --iam-role-arn "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole"  --metadata file://<path to json file>

To define the metadata as parameters within the start-restore-job command, run the command in the following format:

aws backup start-restore-job --region us-east-1 --recovery-point-arn "arn:aws:backup:us-east-1:111222333444:recovery-point:123e4567-6cd9-464e-bb6b-13f70e79d347" --iam-role-arn "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole" --metadata '{"file-system-id": "fs-c1234567", "newFileSystem": "false", "Encrypted": "false", "PerformanceMode":"generalPurpose"}' 

Restore a new EFS file system from an AWS Backup recovery point

1.    Run the list-backup-jobs command to get the ARN of the EFS file system to be restored. You must have the resource ARN to perform an EFS file system restore from an AWS Backup recovery point.

$ aws backup list-backup-jobs --by-resource-type EFS --region us-east-1

2.    In the command output, note the ResourceArn:

{
    "BackupJobs": [
        {
            "CompletionDate": 1584448353.589, 
            "BackupVaultArn": "arn:aws:backup:us-east-1:111222333444:backup-vault:Default", 
            "PercentDone": "0.0", 
            "RecoveryPointArn": "arn:aws:backup:us-east-1:111222333444:recovery-point:f29fe56c-8f44-4877-9ae6-9c6d5dce8935", 
            "ResourceType": "EFS", 
            "BackupSizeInBytes": 73, 
            "State": "COMPLETED", 
            "IamRoleArn": "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole", 
            "ResourceArn": "arn:aws:elasticfilesystem:us-east-1:111222333444:file-system/fs-c1234567", 
            "BackupJobId": "12ddf0b1-aed4-44ec-894f-0d74448949bd", 
            "StartBy": 1584451934.889, 
            "CreationDate": 1584448334.889, 
            "BackupVaultName": "Default"
        }, 
        {
            "CompletionDate": 1583305453.7, 
            "BackupVaultArn": "arn:aws:backup:us-east-1:111222333444:backup-vault:Default", 
            "PercentDone": "0.0", 
            "RecoveryPointArn": "arn:aws:backup:us-east-1:111222333444:recovery-point:09e9dafe-44a6-471a-b4e8-64c98219a480", 
            "ResourceType": "EFS", 
            "BackupSizeInBytes": 73, 
            "State": "COMPLETED", 
            "IamRoleArn": "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole", 
            "ResourceArn": "arn:aws:elasticfilesystem:us-east-1:111222333444:file-system/fs-gd1b761d", 
            "BackupJobId": "721ba96d-a656-4771-a1f4-78bcd0c930f8", 
            "StartBy": 1583309035.684, 
            "CreationDate": 1583305435.684, 
            "BackupVaultName": "Default"
        }
    ]
}

3.    To restore to a new EFS file system, generate a CreationToken value that enforces the uniqueness (idempotency) of the request. The CreationToken can be any value of your choice. On a Linux operating system, you can run the uuid command to generate a unique identifier:

uuid -r 

The output is a universally unique identifier (UUID), similar to the following:

d0c12345-678d-4071-bf30-8e7e54ab65df

4.    To run the start-restore-job command, you must define specific metadata to restore an EFS instance. You can define the metadata in a separate JSON file, or you can define the metadata as parameters within the command.

To define the metadata in a separate JSON file, create a JSON file similar to the following:

Note: For CreationToken, use the CreationToken value that you generated in step 3.

{"file-system-id": "fs-c1234567", "Encrypted": "false", "PerformanceMode": "generalPurpose", "CreationToken": "d0c12345-678d-4071-bf30-8e7e54ab65df", "newFileSystem": "true"}  

Then, run the start-restore-job command:

Note: For --metadata, enter the JSON file that you created in the previous step.

aws backup start-restore-job --region us-east-1 --recovery-point-arn "arn:aws:backup:us-east-1:111222333444:recovery-point:123e4567-6cd9-464e-bb6b-13f70e79d347" --iam-role-arn "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole"  --metadata file://<path to json file>

To define the metadata as parameters within the start-restore-job command, run the command in the following format:

Note: For CreationToken, use the CreationToken value that you generated in step 3.

aws backup start-restore-job --region us-east-1 --recovery-point-arn "arn:aws:backup:us-east-1:111222333444:recovery-point:123e4567-6cd9-464e-bb6b-13f70e79d347" --iam-role-arn "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole" --metadata '{"file-system-id": "fs-17dda397", "newFileSystem": "true", "CreationToken": "d0c12345-678d-4071-bf30-8e7e54ab65df", "Encrypted": "false", "PerformanceMode":"generalPurpose"}'

Did this article help you?

Anything we could improve?


Need more help?