DEV Community

Cover image for Rancher 101 - Making Backups of Rancher (Docker)
Muhammad Abdur Rofi
Muhammad Abdur Rofi

Posted on

Rancher 101 - Making Backups of Rancher (Docker)

Making Backups

Making a backup of Rancher when running as a container involves backing up the persistent data located at /var/lib/rancher inside of the container. Depending on how you started the container, this might be a Docker volume, or it might be a bind-mounted volume on the host.

When creating backups, use an identifier that includes both the date and the rancher version, like rancher-data-backup-v2.3.4-2020-02-07.tar.gz.

Docker Volume

If the container is using a Docker volume, the process for making a backup is as follows:

  1. Stop the container
  2. Create a data container that uses the same volume
  3. Launch a temporary container that extracts /var/lib/rancher to a local tarball
  4. Start the container
  5. Move the backup off of the host.

When making the backup, it's important to use -p with tar to maintain file and directory permissions.

Bind-Mounted Volume

If the container is using a bind-mounted volume on the host, the process for making a backup is as follows:

  1. Stop the container
  2. Create a tarball from the bind-mount directory
  3. Start the container
  4. Move the backup off of the host.

As before, rememberto use -pwith tarto maintain file and directory permissions.

References

Discussion (0)