Skip to content

Instantly share code, notes, and snippets.

@ducas
Created January 8, 2019 00:20
Show Gist options
  • Save ducas/89beda877577d49fc8b1e7014176ccb0 to your computer and use it in GitHub Desktop.
Save ducas/89beda877577d49fc8b1e7014176ccb0 to your computer and use it in GitHub Desktop.
Upgrade single-node Rancher with data volume
#!/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