Skip to content

Single Node Docker Backups

Audience: System Administrators

Content Summary: The Immuta Single Node Docker installation contains functionality to create backup archives used to restore an Immuta installation. By default backups are stored in volumes/immuta-db/backups located inside the immuta installation.

Ensure immuta.toml is present

Although not required, Immuta highly recommends creating an immuta.toml configuration file before proceeding. This is especially helpful if using a custom installation path.

Refer to instructions in Single Node Docker Install, Step 1.

One-time Backup

To take a one-time backup, execute the command below:

/usr/local/bin/immuta-snd backup
Note

Backups can only be taken while Immuta is running.

A backup with filename format immuta-YYYYmmddHHMMSS.tar.gz will be dropped in your Immuta's installation directory (by default /opt/immuta):

/opt/immuta/volumes/immuta-db/backups

Recurring/Scheduled Backups

This section provides a sample backup script that can be used to take a backup and then clean up any old backups. This script may be used to perform the backups either manually when run by an operator or scheduled to run automatically at some periodic interval using a tool like Cron.

Example Backup Script

Below is an example backup script that may be used in a Cron job to backup the Immuta database.

#!/bin/bash

set -e

IMMUTA_HOME="/opt/immuta"
BACKUPS_DIR="${IMMUTA_HOME}/volumes/immuta-db/backups"

# Max number of backups to have. Any number of backups greater than or equal to this number will
# be removed. The number of backups that will exist will be BACKUP_THRESHOLD - 1.
#
# Example: if BACKUP_THRESHOLD=3, then only 2 backups will exist at a given time.
BACKUP_THRESHOLD=3

/usr/local/bin/immuta-snd backup
find "${BACKUPS_DIR}" -type f -name '*.tar.gz' | sort -r | tail -n +${BACKUP_THRESHOLD} | xargs rm -f

Be sure to make the script executable:

chmod +x backup-immuta-task.sh

Schedule Automatic Backups Using Cron

Best Practice: Use Cron to Run Backup Job

Immuta recommends using Cron to run the backup job periodically. The Cron job must have access to the Docker engine, which typically means that it must run as root. You may add the entry in your preferred location, such as /etc/crontab or /etc/cron.d, or you may add it to the root user's configuration by running sudo crontab -e.

Below is an example crontab entry that runs the backup script every day at midnight.

0 0 * * * /opt/immuta/backup-immuta-task.sh > /opt/immuta/backup-immuta-task.log

Backups for Migration to an Immuta Kubernetes Helm Deployment

Migrating the Immuta Docker deployment to a Kubernetes Helm deployment can be done with the Docker backup file. The singular backup file consists of two databases: the Immuta Metadata database (bometadata) and the Immuta Query Engine database (immuta). The Immuta Metadata database and Immuta Query Engine database are separate components for the Immuta Kubernetes Helm deployment; however, the singular backup file can be used as the backup for both components. The file will need to be staged in an appropriate location for the Immuta Metadata and Immuta Query Engine databases.

Example:

cp volumes/immuta-db/backups/immuta-20210512103030.tar.gz <pvc or bucket>/database/immuta-20210512103030.tar.gz
cp volumes/immuta-db/backups/immuta-20210512103030.tar.gz <pvc or bucket>/query-engine/immuta-20210512103030.tar.gz

Once the backup is created, refer to the Import Backups Helm documentation for next steps.

What's Next

Now that you've installed and backed-up Immuta, continue to the next page or to this tutorial: Add a License Key.