Linode CLI: Restore a Backup to a new Linode

Linode Staff

How do I use the Linode CLI to restore a backup to a new Linode?

1 Reply

Checking into our API v4 documentation, I don't believe there is a direct way to restore from a Linode Backup to a new Linode using the Linode CLI as this can be easily done within our Linode Cloud Manager interface.

You will first have to:

  1. Create the new Linode to which you wish to restore the backup, being sure to give it enough resources

  2. Locate the correct backup ID to restore

  3. Restore that specific backup to the new Linode using the Linode CLI.

I've gone ahead and detailed some steps below to restore a backup of your choice to a new Linode. Grabbing the necessary information can be a bit time consuming, however the outcome is worth it once the new Linode has been deployed!

Step 1: Create a new Linode with Enough Resources

When you create your new linode, you'll want to check out the source Linode where your backups are being taken and match those exact parameters using the CLI, like below:

linode-cli linodes create --type g6-standard-2 --region us-southeast --image linode/debian9 --label NewLinode --root_pass

You will then be prompted to enter a password for your new Linode. Once it has been created, be sure to grab the new Linode's ID number.

Please check out these resources for more background on the parameters I used below -

Linode CLI Common Operations

Linode CLI Examples

Step 2: List the Backups for your Existing Linode

In order to view the backups that you can restore for your Linode, the first step is to run the backups-list CLI command for the Linode that you wish to restore and select which backup image you wish to use.

I personally prefer formatting that is easy to read, so I've appended the --json --pretty flags to this command so that the output is a bit more human readable:

linode-cli linodes backups-list 01234567 --json --pretty

In the command above, you will want to replace 01234567 with the numbers from your existing Linode.

Once entered, your output will look a bit like this below:

    "automatic": [
      {
        "configs": [
          "My Debian 9 Profile"
        ],
        "created": "2019-09-01T18:05:16",
        "disks": [
          {
            "filesystem": "ext4",
            "label": "Debian 9 Disk",
            "size": 1728
          },
          {
            "filesystem": "swap",
            "label": "512 MB Swap Image",
            "size": 0
          }
        ],
        "finished": "2019-09-01T18:07:05",
        "id": 000xx111,
        "label": null,
        "region": "us-southeast",
        "status": "successful",
        "type": "auto",
        "updated": "2019-09-01T18:12:41"
      },

From that output, you will want to grab the id number for the backup that you wish to restore.

Step 3. Format the Backup-Restore CLI Command

You will want to collect all 3 pieces of information that we just investigated in order to run this command:

  1. The Original Linode's ID
  2. The Backup ID you wish to restore
  3. The New Linode's ID

The CLI command to restore to the new Linode you created should include the following parameters:

linode-cli linodes backup-restore originalLinodeID backupIDtoRestore --linode_id newLinodeID --overwrite true

Note: In the command above, I've set the --override flag to true in order to delete the empty disks from the new Linode that we created so that we can easily see which disks came from the backup being restored to the new Linode.

Below is a sample of how this command will look once it has been formatted:

linode-cli linodes backup-restore 012345 012345678 --linode_id 0123456 --overwrite true

If all goes well, you should see a notification that a backup restoration was successful from within your new Linode's dashboard in Cloud Manager:

"Backup restoration completed for NewLinode by esyoum."

Additionally in the "Advanced" tab you will see that the disks that came from the restored backup will begin with the word "Restore."

I sincerely hope that these steps have pointed you in the right direction!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct