Booting an instance from a snapshot

Now that we have created an instance snapshot, imagine that we need to go back and recover files, or revert the application to the state it was at the time the snapshot was taken. As the snapshot is stored as an OpenStack image, you can boot directly from the snapshot, and as such all the details required to boot an instance applies to booting a snapshot.

Getting ready

To start an instance from a snapshot, you will need the following:

  • The openstack command-line client
  • The openrc file containing appropriate credentials
  • The name of the instance
  • The snapshot to use for the instance
  • The name of the flavor to create the instance with (this must be of equal or greater size of flavor compared with the one used in the original instance)
  • The name of the network or networks to attach the instance to
  • The keypair name to allow access to an instance
  • The name of any security groups to associate with the instance

How to do it…

The instance we will boot will have the following attributes:

  • Image name: cookbook.test_snapshot-2017-09-08T163619
  • Instance name: cookbook.test_restore
  • Flavor type: openstack.cookbook
  • Network: public (UUID)
  • Keypair name: cookbook_key
  • Security groups: ssh

To boot from an instance snapshot, we use the same process as used when booting an instance. The commands are repeated here:

  1. First, we can list the existing running instances with the following command:
    openstack server list -c Name -c Status
    

    This will bring back a list of ACTIVE running instances:

    How to do it…
  2. We can then boot the instance snapshot using the following command:
    openstack server create
        --flavor openstack.cookbook
        --image cookbook.test_snapshot-2017-09-08T163619
        --nic net-id=6cb5a4ce-1ea5-4817-9c34-a2212a66f394 
        --security-group bd7d5e0f-538a-4d93-b123-98cc3207b3d2 
        --key-name cookbook_key
      cookbook.test_restore
    

    This will bring back the familiar booting an instance output that has been omitted here.

  3. We can now list the running instances again to show our cookbook.test_restore instance is ACTIVE:
    openstack server list -c Name -c Status
    

    This shows our instance is now running:

    How to do it…

How it works…

As instance snapshots are stored as OpenStack images, booting from a snapshot is an identical process to booting from an existing image. There are some caveats however. As snapshots are created while an image is running, booting from them is similar to booting a server after a power failure. You must also ensure that you are using a flavor that is of equal or greater size to the original instance—for example, if an instance was originally created as an m1.large, the snapshot must be booted with an m1.large or greater flavor. Additionally, if the instance is a Windows image attached to an Active Directory domain, it may cause issues having two of the same instances running at the same time. To mitigate this, consider booting the instance onto a separate recovery network.

Tip

There are tools available to quiesce the filesystem inside an instance and provide a more consistent image that are beyond the scope of this book. However, as guidance, ensuring that a filesystem sync (to flush any disk writes) inside the running instance is recommended before a snapshot is taken.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.30.193