Backup and Restore Upgrade a Container - ganeshahv/Contrail_SRE GitHub Wiki

Backup

  1. Create a container as below:

docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /opt/rancher:/var/lib/rancher rancher/rancher:v2.4.1

  1. Stop the container currently running

docker stop <CONTAINER_NAME>

  1. Create a data container from the container that was just stopped.

docker create --volumes-from <CONTAINER_NAME> --name container-data <CONTAINER_IMAGE>

  1. From the data container that was just created, create a backup tarball which will serve as a rollback point if something goes wrong during upgrade.

docker run --volumes-from container-data -v $PWD:/backup busybox tar zcvf /backup/data-backup-<VERSION>-<DATE>.tar.gz /var/lib/docker

  1. Enter the ls command to confirm that the backup tarball was created.

Restore/Upgrade

  1. Pull the image of the Rancher version that you want to upgrade to.

docker pull <CONTAINER_IMAGE>

  1. Start a new container using the data from the data container. Remember to pass in all the environment variables that you had used when you started the original container.

docker run -d --volumes-from container-data --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:latest

  1. Stop the old container

docker rm <CONTAINER_NAME>

⚠️ **GitHub.com Fallback** ⚠️