If you encounter a disaster scenario, you can restore your Rancher Server to your most recent backup.
Before You Start
During restoration of your backup, you’ll enter a series of commands, filling placeholders with data from your environment. These placeholders are denoted with angled brackets and all capital letters (
<EXAMPLE>). Here’s an example of a command with a placeholder:
docker run --volumes-from <RANCHER_CONTAINER_NAME> -v $PWD:/backup \ busybox sh -c "rm /var/lib/rancher/* -rf && \ tar zxvf /backup/rancher-data-backup-<RANCHER_VERSION>-<DATE>"
In this command,
<RANCHER_VERSION>-<DATE> are environment variables for your Rancher deployment.
Cross reference the image and reference table below to learn how to obtain this placeholder data. Write down or copy this information before starting the procedure below.
docker ps Command, Displaying Where to Find
||The rancher/rancher image you pulled for initial install.|
||The name of your Rancher container.|
||The version number for your Rancher backup.|
||The date that the data container or backup was created.|
You can obtain
<RANCHER_CONTAINER_NAME> by logging into your Rancher Server by remote connection and entering the command to view the containers that are running:
docker ps. You can also view containers that are stopped using a different command:
docker ps -a. Use these commands for help anytime during while creating backups.
Using a backup that you created earlier, restore Rancher to its last known healthy state.
Using a remote Terminal connection, log into the node running your Rancher Server.
Stop the container currently running Rancher Server. Replace
<RANCHER_CONTAINER_NAME>with the name of your Rancher container.
docker stop <RANCHER_CONTAINER_NAME>
Move the backup tarball that you created during completion of Creating Backups—Single Node Installs onto your Rancher Server. Change to the directory that you moved it to. Enter
dirto confirm that it’s there.
If you followed the naming convention we suggested in Creating Backups—Single Node Installs, it will have a name similar to
Enter the following command to delete your current state data and replace it with your backup data, replacing the placeholders. Don’t forget to close the quotes.
Warning! This command deletes all current state data from your Rancher Server container. Any changes saved after your backup tarball was created will be lost.
docker run --volumes-from <RANCHER_CONTAINER_NAME> -v $PWD:/backup \ busybox sh -c "rm /var/lib/rancher/* -rf && \ tar zxvf /backup/rancher-data-backup-<RANCHER_VERSION>-<DATE>.tar.gz"
Step Result: A series of commands should run.
Restart your Rancher Server container, replacing the placeholder. It will restart using your backup data.
docker start <RANCHER_CONTAINER_NAME>
Wait a few moments and then open Rancher in a web browser. Confirm that the restoration succeeded and that your data is restored.