Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Backing Up and Restoring a Docker Swarm

For the last six months, the Acme Anvil Corporation has been migrating some of their bare metal infrastructure to Docker containers. A schism has developed between the members of your team on whether to use Docker Swarm or Kubernetes. To settle the dispute, your manager has decided to create a series of challenges. You have been tasked with creating a demo on how to back up and restore a Docker swarm. You are to set up a Docker swarm with 3 nodes, scale the backup service up to 3 nodes, and back up your master node and restore it to a backup instance.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 1h 30m
Published
Clock icon Nov 07, 2018

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Back up the swarm master.

    Stop the docker service on the master node.

    systemctl stop docker
    

    Back up the /var/lib/docker/swarm/ directory.

    systemctl stop docker
    tar czvf swarm.tgz /var/lib/docker/swarm/
    
  2. Challenge

    Restore the swarm on the backup master.

    Copy the swarm backup from the master node to the backup master:

    scp swarm.tar.tgz cloud_user@BACKUP_IP_ADDRESS:/home/cloud_user/
    

    From the backup master, extract the backup file:

    tar xzvf swarm.tar.tgz
    

    Copy the swarm directory to /var/lib/docker/swarm:

    cd /var/lib/docker
    cp -rf swarm/ /var/lib/docker/
    

    Reinitialize the swarm:

    docker swarm init --force-new-cluster
    
  3. Challenge

    Add the worker nodes to the restored cluster.

    Remove each node from the old swarm:

    docker swarm leave
    

    Add each node to the backup swarm:

    docker swarm join --token TOKEN IP_ADDRESS:2377
    
  4. Challenge

    Distribute the replicas across the swarm.

    Scale the replicas down to 1:

    docker service scale backup=1
    

    Next, scale the replicas up to 3 to distribute the replicas across the swarm:

    docker service scale backup=3
    

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans