Created
November 15, 2018 21:05
-
-
Save mak3r/3c4e41cb7ac94daddb4980f79f904336 to your computer and use it in GitHub Desktop.
Rancher v2.x single node upgrade
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 | |
# based on | |
# https://rancher.com/docs/rancher/v2.x/en/upgrades/upgrades/single-node-upgrade/ | |
RANCHER_CONTAINER_NAME=$1 | |
RANCHER_CONTAINER_TAG=$2 | |
RANCHER_VERSION=$3 | |
RANCHER_UPGRADE_VERSION=$4 | |
if [ "$#" -ne 4 ]; then | |
echo "Usage: $0 <RANCHER_CONTAINER_NAME> <RANCHER_CONTAINER_TAG> <RANCHER_VERSION> <RANCHER_UPGRADE_VERSION>" >&2 | |
exit 1 | |
fi | |
docker stop $RANCHER_CONTAINER_NAME | |
docker create --volumes-from $RANCHER_CONTAINER_NAME --name rancher-data rancher/rancher:$RANCHER_CONTAINER_TAG | |
# Improve this script by checking if the archive exists or using a date stamp with time included | |
# if it does then warn the user | |
# The way it's written, you can only create the backup 1x per day or you'll clobber the prior backup | |
docker run --volumes-from rancher-data -v $PWD:/backup alpine tar zcvf /backup/rancher-data-backup-$RANCHER_VERSION-$(date '+%F').tar.gz /var/lib/rancher | |
docker pull rancher/rancher:$RANCHER_UPGRADE_VERSION | |
docker run -d --volumes-from rancher-data --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:$RANCHER_UPGRADE_VERSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exactly what I need!