Restore a Swarm
Let's learn how to restore a backed-up swarm.
We'll cover the following
Perform restoration
The steps in the following procedure demonstrate how to perform a restore. Performing a restoration in the real world may be slightly different, but the overall process will be similar.
Note: You do not have to perform a restore operation if your swarm is still running and you only wish to add a new manager node. In this situation just add a new manager. A swarm restore is only for situations where the swarm is corrupted or otherwise lost and you cannot recover services from copies of config files stored in a source code repo.
We’ll use the swarm.bkp
file from
earlier
to restore the swarm. All swarm nodes must have their Docker daemon stopped and the contents of their /var/lib/docker/swarm
directories deleted.
The following must also be true for a recovery operation to work:
- You can only restore to a node running the same version of Docker the backup was performed on
- You can only restore to a node with the same IP address as the node the backup was performed on
Getting started
Perform the following tasks from the swarm manager node that you wish to recover. Remember that Docker must be stopped and the contents of /var/lib/docker/swarm
must be deleted.
1.) Restore the Swarm configuration from backup.
In this example, we’ll restore from a zipped tar
file called swarm.bkp
. Restoring to the root directory is required with this command as it will include the full path to the original files as part of the extract operation. This may be different in your environment.
Get hands-on with 1400+ tech skills courses.