Last active
July 5, 2021 04:52
-
-
Save michaelact/8a759499dcbecc816b6ce5f9125d87e3 to your computer and use it in GitHub Desktop.
How to backup your Docker Swarm Cluster?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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