Docker: how to backup and restore a swarm manager.
Docker manager nodes store the swarm state and manager logs in the /var/lib/docker/swarm/ directory, without the state you cannot restore the swarm. We don't need to take a backup from all swarm nodes since all should keep the same state.
To take a backup
sudo systemctl stop docker
sudo tar -zvcf backup.tar.gz -C /var/lib/docker/swarm .
sudo systemctl start docker
To restore from backup
sudo systemctl stop docker
sudo rm -rf /var/lib/docker/swarm/*
sudo tar -zxvf backup.tar.gz -C /var/lib/docker/swarm/
sudo systemctl start docker
docker node ls