Link Search Menu Expand Document

Backup and Restore EC2 Instances

Table of Contents

Run Backups as background jobs

This option is the default and allows the user to run backup and restore operations for agentless backups such as EC2 and EBS backups as background jobs or run in the background while other processes continue.

Examples

Here is an example of the backup command that will be executed in the background with monitoring on:

elastio ec2 backup --instance-id <aws-ec2-instance-id> --monitor

Here is an example of the backup command that will be executed in the background without monitoring on:

elastio ec2 backup --instance-id <aws-ec2-instance-id>

Even without the monitoring option, once the background job has started, you can still monitor it with the elastio job monitor command provided in the output.

Additionally, any EC2 recovery point can be scanned for filesystem integrity. It can be done wither right after the backup is completed by running:

elastio ec2 backup --instance-id <aws-ec2-instance-id> --fs-check

or by separately launching this check with the following command:

elastio fs-check --rp <elastio-rp-id>

Run Restores as background jobs

The restore functionality is, in essence, identical to the backup-as-background job and is the default. An agent instance will spin out, taking care of the restore.

Note: When running an EC2 restore, an identical instance with all its attributes, including instance type, volumes attached, Operating System (OS), directory and file structure, and more will be launched in the account and region where your Elastio CLI is running.

The Elastio CLI can run on any machine, localhost, or instance of any type. An example command of how to instantiate an EC2 restore is as follows:

sudo -E elastio ec2 restore --rp <elastio-rp-id> --monitor

Note: --rp is defined in the following ways:

    ELASTIO_RP_ID, e.g. r-dfa1xkmb7bqordtqpedc1wgu
        Recovery point ID.

    @
        The most recent recovery point. '@' should be used on Wndows.

    @~[<n>], e.g. @~, @~5
        The <n>th recovery point before the latest one.
        @~ is equivalent to @~1; @~0 is equivalent to @.

    @{<date>}, e.g. @{2021-04-30 11:15}
        Specifies the value of the recovery point at a prior point in time.
        Note that this looks up the latest recovery point at a given time.

Here is a practical example of what this command should look like:

sudo -E elastio ec2 restore --rp @ <aws-ec2-instance-id>

You can also add a name tag to the restored instance to make it more discoverable, using the --name flag as follows:

sudo -E elastio ec2 restore --rp <elastio-rp-id> --name RESTORED_INSTANCE_NAME

Foreground EC2 Backups and Restores

For foreground EC2 backups and restores, use a Nitro instance to install and run the Elastio CLI on an AWS EC2 instance. It is optimized for fast EC2 backups. Consequently, running EC2 backups or restores on another instance-type might result in an error.

Backup an EC2 instance in foreground

Use the following command to back up an EC2 instance in foreground:

sudo -E elastio ec2 backup --instance-id <aws-ec2-instance-id> --foreground

Here is a practical example of what this command must look like:

sudo -E elastio ec2 backup --instance-id <aws-ec2-instance-id> --foreground

Restore an EC2 instance in foreground

The following commands or instructions will restore your EC2 recovery points or backups in foreground.

Use this command to return a list of available backups:

elastio rp list --ec2

Here is a practical example of what this command must look like:

elastio rp list --ec2 <aws-ec2-instance-id>

Use the following command to select a recovery point from this list and start the restore in foreground:

sudo -E elastio ec2 restore --rp <elastio-rp-id> --foreground

There is an option to change the security group for the restored instance, to do so use the --sg-ids option like so:

elastio ec2 restore --rp <elastio-rp-id> --sg-ids <security-group-id>

Encrypt an EBS volume from an EC2 RP or during an EC2 restore

By default, Elastio restores EC2 volumes to represent the same state that they were in at the time of backup: Encrypted as encrypted and unencrypted as unencrypted. Elastio now provides a way to override this default.

The following commands describe how to restore an EC2 volume “as is” at backup and how to change its encryption status:

Use the following command to restore an EC2 volume that was encrypted as encrypted (no additional flags are required):

sudo -E elastio ec2 restore --rp <elastio-rp-id>

Use the following command to restore an EC2 volume that was unencrypted as unencrypted (no additional flags are required):

sudo -E elastio ec2 restore --rp <elastio-rp-id>

Use the following command to restore an encrypted EC2 volume as encrypted and encrypt it with the default AWS managed key:

sudo -E elastio ec2 restore ---rp <elastio-rp-id> --encryption apply

Use the following command to restore an encrypted EC2 volume as encrypted and encrypt it with another key:

sudo -E elastio ec2 restore --rp <elastio-rp-id> --encryption apply --kms-key <aws-kms-key-arn>n>

Use the following command to restore an EC2 volume that was not encrypted on backup and encrypt it with the default AWS managed key:

sudo -E elastio ec2 restore ---rp <elastio-rp-id> --encryption apply

Use the following command to restore an EC2 volume that was not encrypted on backup and encrypt it with another key:

sudo -E elastio ec2 restore --rp <elastio-rp-id> --encryption apply --kms-key <aws-kms-key-arn>

Use the following command to restore an EC2 volume that was encrypted on backup as unencrypted:

sudo -E elastio ec2 restore --rp <elastio-rp-id> encryption disable

Shrink an EC2 instance

Elastio makes it easy to decrease the size of the EBS volume(s) in your EC2 instance. It allows you to create new disk space from the existing disk. Before an instance can use the space on the disk to store data, the disk needs to be split up into separate areas called partitions. Shrinking an EBS volume in your EC2 instance implies reducing the size of the partition(s).

The Elastio CLI can shrink an EBS volume in your EC2 instance on any machine, localhost or instance of any type. Elastio performs the shrink operation as a background job within your AWS account. An EC2 instance is launched to perform the actual backup, restore and shrinking, and is terminated when the operations are completed. It should also be mentioned that shrinking functionality is available upon restore only.

The operation starts with selecting and analyzing a recovery point and terminates with creation of a new EBS volume of the new target size. All modifications to the disk performed by the shrink operation will be in the sparse file on the disk. Consequently, it requires that sparse file is on a partition with enough space for all of the writes to be performed on the filesystem as part of the shrink operation.

Set the target size of the EBS volume in your EC2 instance in order to shrink a partition.

  1. You may request a target size (which may or may not be possible to achieve).

  2. You may request the smallest possible size.

  3. You may request the smallest possible size + some fixed number of free megabytes to support additional work.

Use the following command to restore the EBS volume to the target size:

elastio ec2 restore --rp <elastio-rp-id> --monitor --shrink "<aws-ebs-volume-id>=len 12GiB""

To request the smallest possible size, the following command is needed:

elastio ec2 restore --rp <elastio-rp-id> --monitor --shrink "<aws-ebs-volume-id>=max"

Use the following command to request the smallest possible size + some fixed number of free megabytes to support additional work.

elastio ec2 restore --rp <elastio-rp-id> --monitor --shrink "<aws-ebs-volume-id>=leave 8GiB"

The supported file systems are NTFS, Ext2/Ext3/Ext4 and XFS.