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

Last updated: 2022-01-05

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.

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 recovery point 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

Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.

2.    In the command output, note the RecoverypointArn:

{
    "BackupJobs": [
        {
            "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:123e4567-6cd9-464e-bb6b-13f70e79d347", 
            "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-6a1dcba2", 
            "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-6a1dcba2", "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-6a1dcba2", "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 recovery point 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 RecoverypointArn:

{
    "BackupJobs": [
        {
            "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:123e4567-6cd9-464e-bb6b-13f70e79d347", 
            "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-6a1dcba2", 
            "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-6a1dcba2", "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-6a1dcba2", "newFileSystem": "true", "CreationToken": "d0c12345-678d-4071-bf30-8e7e54ab65df", "Encrypted": "false", "PerformanceMode":"generalPurpose"}'

Perform an item-level EFS file system restore 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 recovery point 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

Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.

2.    In the command output, note the RecoverypointArn:

{
    "BackupJobs": [
        {
            "AccountId": "686948106210",
            "BackupJobId": "261f13d0-5ede-458e-a00e-d83ed5de0afe",
            "BackupVaultName": "Default",
            "BackupVaultArn": "arn:aws:backup:us-east-1:111222333444:backup-vault:Default",
            "RecoveryPointArn": "arn:aws:backup:us-east-1:111222333444:recovery-point:123e4567-6cd9-464e-bb6b-13f70e79d347",
            "ResourceArn": "arn:aws:elasticfilesystem:us-east-1:111222333444:file-system/fs-6a1dcba2",
            "CreationDate": "2021-08-23T07:52:56.652000+00:00",
            "CompletionDate": "2021-08-23T07:53:09.547000+00:00",
            "State": "COMPLETED",
            "PercentDone": "100.0",
            "BackupSizeInBytes": 75,
            "IamRoleArn": "arn:aws:iam::111222333444:role/service-role/AWSBackupDefaultServiceRole",
            "StartBy": "2021-08-23T08:52:56.652000+00:00",
            "ResourceType": "EFS"
        }

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-6a1dcba2", "newFileSystem": "false", "Encrypted": "false", "PerformanceMode":"generalPurpose", "itemsToRestore":"[\"/my.test\"]"}

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-6a1dcba2", "newFileSystem": "false", "Encrypted": "false", "PerformanceMode":"generalPurpose", "itemsToRestore":"[\"/my.test\"]"}'

Did this article help?


Do you need billing or technical suppport?