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 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
|
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
You can use migration backup to migrate a configuration to a new major version of OP5 Monitor.
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.
|
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.