Created
January 8, 2019 00:20
-
-
Save ducas/89beda877577d49fc8b1e7014176ccb0 to your computer and use it in GitHub Desktop.
Upgrade single-node Rancher with data volume
This file contains hidden or 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 | |
old_id=$1 | |
old_version=$2 | |
new_version=$3 | |
now=`date +%Y%m%d-%H%M%S` | |
echo "Stop $2 ($1)" | |
docker stop $1 | |
echo "Create new volume" | |
docker create --volumes-from $1 --name rancher-data rancher/rancher:$3 | |
echo "Backup data" | |
docker run --volumes-from rancher-data -v $PWD:/backup alpine tar zcvf "/backup/rancher-data-$2-$now.tar.gz" /var/lib/rancher | |
echo "Run $3" | |
docker run -d --volumes-from rancher-data --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:$3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment