Disk Image - Restore To Amazon AWS

Creating a Virtual Machine in the AWS cloud from a Magnus Box Disk Image Backup

Useful Resources:


You will need:

  • An AWS account and API access keys for it
  • Access to EC2 and S3 using your API access keys
  • A correctly configured AWS EC2 environment
  • A Magnus Box disk image backup configured and restored

Note: All example commands executed in Windows Command Prompt or Mac Terminal.

A future version of Magnus Box may automate many of the following steps.

Part 1: Configuring AWS

Create S3 Storage Bucket

In the AWS Management Console,

  • Click "Services" --> "S3" (Storage section)
  • Click "Create Bucket" in the upper-right part of the screen

  • Name the bucket (ex. disk-image-restore-mb)
  • Create the bucket via the button at the bottom of the page

Create AWS User Account

Inside the AWS Management Console,

  • Click "Services" --> "IAM" (Security, Identity, & Compliance)
  • Click the "Users" link and the "Add User" button on the next page

  • Name the user, then select "Programmatic access" for the access type

  • On the next page, attach the permissions manually, selecting:
    • AdministratorAccess 
    • AdministratorAccess-Amplify 
    • AdministratorAccess-AWSElasticBeanstalk
  • Navigate to the final page, leaving the other settings at their default value
  • Create the User, making sure to save or download the produced Access Key ID and Secret Access Key

Download and Configure the AWS CLI

Download the CLI from Amazon's Download page. Then,

  • Open the Command Prompt on Windows or Terminal on Mac
  • Run aws configure
  • Input the Access Key Id and Secret Access Key from the User generated in the previous step
  • You can leave the "Default region name" blank
  • Enter json as the "Default output format"

A "vmimport" Service Role is also required to complete the upload to AWS. Full instructions can be found on Amazon's documentation article (steps 1-3, 6).

  • When creating the role-policy.json file, the same S3 bucket can be used to replace the disk-image-file-bucket and export-bucket fields.
  • Ensure that the following /* are present in the second line for each S3 resource.

Part 2: Restore VMDK Files

Perform restore in Magnus Box to create VMDK files

  • Note: The restored files will be the same size as the original disk size, so ensure you have enough space in your restore location.

  • Produces files as shown below (the number of files will vary based on the device's partitions)

Concatenate Individual Files

  • To restore all partitions of a particular drive, the individual image files must be combined. Do not include the 1 KB disk.vmdk since it does not contain necessary binary information.
    • To combine files on Windows:  cmd /c copy /b .\disk_f0000.vmdk+.\disk_f0001.vmdk+.\disk_f0002.vmdk diskname.vmdk
    • To combine files on Linux or Mac: cat disk_f0000.vmdk disk_f0001.vmdk disk_f0002.vmdk > diskname.vmdk
    • Note: These are only example commands and may differ if more or less partitions exist
  • After combining, the following file should be present:

Upload the VMDK file to the AWS folder

  • Example commands:
    • Windows: aws s3 cp .\diskname.vmdk s3://bucketname/subfolder/
    • Mac: aws s3 cp diskname.vmdk s3://bucketname/subfolder/
    • These commands assume the command window is in the same working directory as the diskname.vmdk file. Use of the cd command is useful in navigating to the correct directory from a command window
  • Verify the contents of the storage folder: aws s3 ls bucketname/subfolder/
    • (note the trailing '/')
  • Create a local file.json file named disk-container.json for importing the image into AWS Example:
[
    {
        "Description": "meta data",
        "Format": "raw",
        "UserBucket": {
            "S3Bucket": "bucketname",
            "S3Key": "subfolder/diskname.vmdk"
        }
    }
]

Run the AWS import-image command with file.json as parameter

  • Example command: aws ec2 import-image --region <yourregionname> --disk-containers "file://C:\path\to\file.json"
  • Initial response similar to:

Note the 'ImportTaskId' in the form of: “import-ami-XXXX”

  • Example command to show ongoing progress: aws ec2 describe-import-image-tasks --import-task-ids import-ami-XXXX --region <yourregionname>
  • Ongoing progress similar to:

When the command to show ongoing progress returns “Status”: “completed”, note down the AMI ID

Connect via RDP

  • Log in to AWS website
  • Select ‘Services’ drop-down
  • Select ‘EC2’

  • Select 'AMIs'
  • Tick to select the AMI ID from the previous step
  • Actions
  • Launch

  • Configure and launch

  • Select the launched instance
  • Select Connect
  • Download remote connection details
  • Use your preferred Remote Desktop program to connect using the downloaded details
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us