Backup and Restore

This section details how to back-up and restore Horizon. Back-up and restore operation can be performed using the back-up and restore tool available under /opt/horizon/sbin/horizon-backup. It is designed to be used only in RPM-Based deployments.

For Docker or Kubernetes based deployments, the configuration should be managed by the Docker/Kubernetes management platform, and the database should be backed-up using MongoDB tools.

Backup Procedure

This section details how to back up Horizon configuration elements.

Several elements can be backed up:

  • The Horizon configuration files.

  • The Horizon MongoDB.

The backup tool allows backing up these elements independently.

$ /opt/horizon/sbin/horizon-backup --help
 usage: horizon-backup [-cdho:qs]
 	-c | --conf          Backup the configuration files
 	-d | --db            Backup the MongoDB database
 	-h | --help          Display the 'horizon-backup' help
 	-o | --output [path] Specify the backup output folder (default: '/opt/horizon/var/backup')
 	-q | --quiet         Quiet mode

To back up the configuration files, run the following command:

$ /opt/horizon/sbin/horizon-backup -c

The configuration files backup consists of a compressed archive (.tar.gz) located under /opt/horizon/var/backup/.

To back up the MongoDB database, run the following command:

$ /opt/horizon/sbin/horizon-backup -d

The MongoDB database backup consists of a compress file (.gz) located under /opt/horizon/var/backup/.

To run a complete backup, execute the following command:

$ /opt/horizon/sbin/horizon-backup -c -d
  • The backup output folder can be overridden using the -o | --output parameter

  • The backup tool can operate in quiet mode (when scheduled in a cron job) using the -q | --quiet parameter

Restoration Procedure

This section details how to restore horizon configuration elements.

This restore procedure only applies to the exact same application version as the backup file.

Restoration operation should be performed while the Horizon service is not running. Stop the Horizon service with the following command:

$ systemctl stop horizon

To restore a configuration backup, run the following command:

$ tar xzpvf [horizon configuration backup archive path] -C/

To restore the MongoDB database, run the following command:

$ mongorestore --uri="[MongoDB URI]" --drop --gzip --archive=[horizon MongoDB backup archive path]

The MongoDB URI can be retrieved from the /etc/default/horizon/_* configuration file, as MONGODB_URI parameter.

The Horizon service can now be started with the following command:

$ systemctl start horizon