- Lab
- A Cloud Guru
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.
Path Info
Table of Contents
-
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/
-
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
-
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
-
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
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.