How to Create a Docker Backup With Morpheus

By: Morpheus Data

Docker and Morpheus go together like bread and butter. Want proof? Look no further than the process of creating container backups, which are an essential element of Docker management.

Consider this typical scenario: You’ve created a data volume for your container and now want to backup both the changes to the container and the container data volume. Backing up the container changes is as easy as committing and pushing the image to Docker Hub, or alternatively to your locally stored private cloud.

That leaves the data volume unprotected because, by definition, the data volume is not committed as part of the image. You need to commit the data volume because when you work on a cluster, such as coreOS, you don’t know where the image is going to run. That’s why you need access to the data volume along with the image.

The manual method for backing up, restoring, and migrating data volumes is presented in this Docker tutorial. That approach stores the volumes locally. DZone‘s Eran Avidan extends the technique to allow the backup to be pushed to Docker Hub so it can be restored to any location.

Automate Container Backups in a Flash via the Morpheus Dashboard

If you like entering arcane operators from the command line, you’ll love these manual container backup techniques. Keep in mind, there’s a faster and more efficient way to backup containers that’s just as effective: Let Morpheus do the heavy lifting.

Step 1: Add a Docker Host to Any Cloud

As explained in a tutorial on the Morpheus support site, you can add a Docker host to the cloud of your choice in a matter of seconds. Start by choosing Infrastructure on the main Morpheus navigation bar. Select Hosts at the top of the Infrastructure window, and click the ‘+Container Hosts’ button at the top right.

To back up a Docker host to a cloud via Morpheus, navigate to the Infrastructure screen and open the ‘+Container Hosts’ menu. Source: Morpheus

Choose a container host type on the menu, select a group, and then enter data in the five fields: Name, Description, Visibility, Select a Cloud and Enter Tags (optional). Click Next, and then configure the host options by choosing a service plan. Note that the Volume, Memory, and CPU count fields will be visible only if the plan you select has custom options enabled.

Here is where you add and size volumes, set memory size and CPU count, and choose a network. You can also configure the OS username and password, the domain name, and the hostname, which by default is the container name you entered previously. Click Next, and then add any Automation Workflows (optional). Finally, review your settings and click Complete to save them.

Step 2: Add Docker Registry Integration to Public or Private Clouds

Adam Hicks describes in another Morpheus tutorial how simple it is to integrate with a private Docker Registry. (No added configuration is required to use Morpheus to provision images with Docker’s public hub using the public Docker API.)

Select Integrations under the Admin tab of the main navigation bar, and then choose the ‘+New Integration’ button on the right side of the screen. In the Integration window that appears, select Docker Repository in the Type drop-down menu, enter a name and add the private registry API endpoint. Supply a username and password for the registry you’re using, and click the Save Changes button.

Integrate a Docker Registry with a private cloud via the Morpheus ‘New Integration’ dialog box. Source: Morpheus

To provision the integration you just created, choose Docker under Type in the Create Instance dialog, select the registry in the Docker Registry drop-down menu under the Configure tab, and then continue provisioning as you would any Docker container.

Step 3: Manage Backups

Once you’ve added the Docker host and integrated the registry, a backup will be configured and performed automatically for each instance you provision. Morpheus support provides instructions for viewing backups, creating an instance backup, and creating a server backup.

Start by choosing Backups on the main navigation bar. Select Backups on the sub-navigation bar that appears, and click the backup name to view details about it. To create an instance backup, click the Add Backup button, which opens the Create Backup Wizard.

Select the Instance radio button in the wizard, give the backup job a name, and choose the instance you want to backup from the drop-down menu. Click Next, and then enter such pertinent details as the database name, username, password, and container. Click Next again, and then schedule your backup by choosing the days and time. Click Complete to save and activate the backup.

Step 4: Configure and Integrate Backups

To alter or disable a scheduled backup, select the Admin tab on the main navigation bar and choose Backups on the sub-navigation bar. In the Backup Settings window, you can toggle on and off the options for Scheduled Backups, Backup Appliance, and Default Backup Provider. You can also pick your default backup provider via the drop-down menu, and enter the minimum number of successful backups to retain.

Step 5: Provision a Docker Host into Hyper-V

An article on Morpheus support about Hyper-V integration highlights a great timesaver for any Docker installation: the ability to support multiple containers per Docker host. The Add Instance catalog in Provisioning is used to provision virtual machine-based instances.

Start by provisioning the Docker host in Hyper-V by navigating to the Cloud detail page or the Infrastructure Hosts section. Choose the ‘+Container Host’ button to add a Hyper-V Docker host. Morpheus treats the host like any other Hypervisor, except that it is used to run containerized images rather than virtualized ones. A green checkmark indicates that the Docker host has been provisioned successfully and is ready for use.

If the provisioning fails, an explanation of the error appears when you click into the relevant host. For example, a network connectivity glitch may be traced to the host’s inability to resolve the Morpheus appliance URL. This setting can be configured in Admin > Settings.