OP5 Monitor ["OP5 Monitor"]
["Technical Reference"]["User Guide"]

Back up and restore

Overview

It is important to back up your application to be able to restore configuration and important data in case of a system failure. This page provides you the information on how you can back up the system in several ways.

op5backup

For Linux systems where there is no backup facility, we provide a backup utility called op5backup that can create backups of system configuration data and OP5 Monitor product configurations and data.

op5backup consists of a backup script and a restore script. The backup script op5-backup can be scheduled to run using cron, and it can place the backups in a local or remote mounted directory, or transfer the file to another server over FTP.

op5backup does not back up op5-logserver logs, so you need to set up remote archiving for this, or back them up manually.

To obtain a list of all op5backup functions available, run the following command:

op5-backup --help command

Configuration

The main configuration file for op5backup is in file /etc/op5-backup/main.conf.

You need to set the following configuration variables:

Variable Description
transfer=

The file set this to ftp, sftp or local. If you set this to:

  • local, set storagepath
  • ftp or sftp, set backupserver, backuppath, backupuser, and backuppass
storagepath= Path to local backup storage location.
backupserver= FQDN or IP address of your FTP or SFTP server.
backuppath= Path to remote backup storage location.
backupuser= User name for the FTP or SFTP account.
backuppass= Password for the FTP or SFTP account.

If you have added software or data to your system that you want to include in the backup, you need to add it to the /etc/op5-backup/modules/custom file.

The backup modules are written in bash and use a set of variables and functions. The table below describes the variables used in a backup module script

Variable Description
DESCRIPTION A short description of the module.
FILES_TO_BACKUP The files and folders to backup with this module. It can contain single files, file names with wildcards like *, and whole folders.
WORK_DIR The folder where the file is stored temporarily during the backup. Make sure there is enough free space in the specified location.

The following table describes the functions used in an op5-backup module:

Function Description
CHECK Used to check if it is ok to perform the backup specified in this backup module. If it is ok, it returns 0, if not it returns 1.
BACKUP_ACTION Used to specify actions performed before the actual backup is performed.
RESTORE_ACTION Used to specify what to do after a restore is performed.

Schedule backups

To set up cron to execute a backup script you need to edit file /etc/cron.d/op5backup.

For example, for backups every day at 01.59 enter the following:

59 1 * * * root /usr/sbin/op5-backup >/dev/null 2>&1

For more information about the cron file, execute the following command:

man 5 crontab

Silent backup

It is possible to perform a backup without any output from the backup script, with the following command:

# op5-backup -b

To view the backup log during the backup, use the following command:

# tail -f /var/log/cron

Migration

This section outlines the process of migrating a standalone OP5 instance to a new IP address, independent of the MON8 instance's IP.

You can use migration backup to migrate a configuration to a new major version of OP5 Monitor.

Warning: Due to an issue in the migration script, you can only upgrade from OP5 Monitor 8.4.2 to 9.4. Migrating to OP5 Monitor 9.3 and below will cause an error.

We recommend that you directly upgrade to OP5 Monitor 9.4 or newer.

You can run a migration using the following command:

 op5-backup -g

No other arguments are needed when using the migration option, it uses the backup configuration.

The migration backup files will have a migration_ as a prefix to the file name.

When upgrading or reinstalling a system using the migrate option, you need to ensure you move the backup file from the server before erasing the file system.

Interactive backup

To run an interactive backup with a graphical interface, run the following command:

op5-backup -i

This command starts an ncurses user interface, where you can specify how and where to backup. You can choose between migration and normal backup.

Backup verification

To verify a backup file, run the following command:

# tar vft <op5-backup_file>

This lists all the files in the backup file. If no files are listed, the backup file might be corrupt.

Override configuration settings

To override the configuration file, run the following command:

op5-backup -o 

Setting this makes op5-backup ignore the default configuration file, /etc/op5-backup/main.cfg. You can add backup arguments, as described below.

Backup arguments

Argument Description
-t local|ftp|sftp Type of transfer to the storage where the backup file will be saved.
-d <any/dir/> The directory in which to save the backup file. Valid for all transfer types.
-s <remote.host> Remote server to connect to.
-u <user_name> User name when -t is set to ftp or sftp.
-p <password> Password to use when -t is set to ftp or sftp. If you do not set -p <password> as an argument, you will be asked for it.

Migrate peer and poller to OP5 Monitor 9.x

This section outlines the peer and poller migration process from OP5 Monitor 8.x.x to OP5 Monitor 9.x, focusing on reusing original IP addresses for all instances to minimize migration efforts.

Prerequisites

Ensure all prerequisites are met for each OP5 Monitor 8 instance before creating a full backup using op5-backup -g prior to its upgrade to OP5 Monitor 9.

  • For each MON8 instance to be upgraded, a corresponding MON9.x instance must exist as the target for the backup restoration.

  • The number of master, peer, and poller instances for MON8 and MON9 should match.

To perform a MON8 to MON9 upgrade on all master, peer, and poller instances using their respective IP addresses, the following steps are required.

  1. Execute op5-backup -g on all MON8 OP5 instances.

  2. Verify that backup files are created for master, peers, and pollers. Save these backup files locally.

  3. Shutdown all MON8 instances after copying the generated backups. This ensures no duplicate IPs are encountered when restoring backups to MON9 instances.

  4. Transfer the backup files to their corresponding OP5 version 9.x instances. For example, a setup with one Master, one Peer, and one Poller requires three OP5 version 9.x instances for backup restoration: one for the Master, one for the Peer, and one for the Poller.

  5. Execute op5-restore -b <backup file> and select Yes to apply the network settings of MON8.

  6. If you have a Merlin encryption setup, the public keys used for encryption from each node are not included in the OP5 backup. Ensure you execute rsync again to back up the public keys separately, as they are not part of the backup file. Verify that the public key names match those configured in /opt/monitor/op5/merlin/merlin.conf. Note that this step is optional.

    In this example, there is one Master, one Peer, and one Poller; therefore, the syncing would look like this.

    On Master:

    rsync -a /opt/monitor/op5/merlin/key.pub <Peer IP>:/opt/monitor/op5/merlin/<master_public_key>.pub
    rsync -a /opt/monitor/op5/merlin/key.pub <Poller IP>:/opt/monitor/op5/merlin/<master_public_key>.pub

    On Peer:

    rsync -a /opt/monitor/op5/merlin/key.pub <Master IP>:/opt/monitor/op5/merlin/<peer_public_key>.pub
    rsync -a /opt/monitor/op5/merlin/key.pub <Poller IP>:/opt/monitor/op5/merlin/<peer_public_key>.pub

    On Poller:

    rsync -a /opt/monitor/op5/merlin/key.pub <Master IP>:/opt/monitor/op5/merlin/<poller_public_key>.pub
    rsync -a /opt/monitor/op5/merlin/key.pub <Peer IP>:/opt/monitor/op5/merlin/<poller_public_key>.pub
  7. Restart all instances.

Restore backups

To restore a backup, execute op5-restore with the backup file as an argument:

/usr/sbin/op5-restore [-h] -b backup_file [ -f ] [module...]

Options:

  • -h — shows this help.
  • -b — the path to the backup file to restore from.
  • -f — restore files only. Do not execute any post-restore actions, such as restoring the database from a dump.