Skip to content

Instantly share code, notes, and snippets.

@michaelact
Last active July 5, 2021 04:52
Show Gist options
  • Save michaelact/8a759499dcbecc816b6ce5f9125d87e3 to your computer and use it in GitHub Desktop.
Save michaelact/8a759499dcbecc816b6ce5f9125d87e3 to your computer and use it in GitHub Desktop.
How to backup your Docker Swarm Cluster?
#!/bin/bash
service docker stop
if [ $# -eq 2 ]
then
if [ $1 = 'backup' ]
then
tar -czvf $2 /var/lib/docker/swarm
elif [ $1 = 'restore' ]
then
tar -zxvf $2 -C /
echo "Run: docker swarm init --force-new-cluster to re-clustering docker environment."
else
echo "Command $1: Not found!"
fi
else
echo "Run Syntax: bar-docker [backup|restore] filename"
service docker start
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment