Engine backup and restore

Contents

Engine backup and restore

Manual backup

To make a complete backup of the Engine, execute manually the same script that is executed automatically during the daily backup of the Appliance:

  1. Log in to the CLI of the Appliance running the Engine.
  2. Execute the command:
    sudo /var/nexthink/engine/common/bin/nightly_backup.sh
  3. Optionally: If you want to keep the logs, copy the log files stored under:
    /var/log/nexthink/
    • engine.log
    • audit.log
    • alert.log
    • All the compressed older logs stored in gz files.

For every instance of the Engine in the Appliance, the script creates a tgz file (GZIP compressed Tar archive format) with the contents of the Engine database and its configuration. Find the backup files under:

/var/nexthink/engine/<instance_number>/backups/nxengine-backup-<id>.tgz

Alternatively, you can make a backup of the Engine database only. Copying the database file while the Engine is running is not a good idea, because the Engine is continuosly modifying the file, and the result could be a corrupted file. Instead, make a safe backup while your Engine is running by following these steps:

  1. Log in to Command Line Interface of the Appliance.
  2. Execute the following command to generate a compressed gz file with the database of the Engine:
    nxinfo backup [--engine <instance_number>] --name <name_of_backup_file>

The file is copied to your current directory.

Automatic backup

The Appliance automatically makes a backup of all the Engines running on it via a cron job. The job is executed every day at 04h15 by default. Find the cron job specification under:

/etc/cron.d/nxengine-crontab

And the script executed in here:

/var/nexthink/engine/common/bin/nightly_backup.sh

The script makes a copy of each one of the the databases and the configuration of the Engines that are present in the Appliance and compresses them in separate tgz files. Backup files are stored in the instance backup directory:

/var/nexthink/engine/<instance_number>/backups/nxengine-backup-<id>.tgz

Specify the maximum number of local backups that are kept in the directory by editing the first variable in the script nightly_backup.sh. By default, up to ten backups are kept simultaneously:

NUM_OF_BACKUPS=10

In a test environment, you may want to disable automatic backups to save disk space in the Appliance. To that end, comment out the line that executes the nightly backup in the crontab file by prepending a hash sign (#) to it.

Each local backup file gets assigned a number from one to the maximum number of simultaneous backups in the directory. When the maximum number is reached, the count begins again and backup files are progressively overwritten. In order to get the most recent backup file, there is a symbolic link to the latest backup (note the absence of identifier):

/var/nexthink/engine/<instance_number>/backups/nxengine-backup.tgz

If external backups have been activated, the automatic script copies the daily backup to external storage right after generating it.

Restoring the Engine

Restore the Engine either in the same Appliance from which you made the backups or in a different Appliance. In the case that you are restoring your backups in another Appliance, make sure that its network configuration is the same as the configuration of the original Appliance. Otherwise, you may no longer receive data from the Collectors and have the wrong internal networks configured. In addition, the new Appliance requires you to reallocate the devices assigned to the original Appliance from the Portal. In case that you are using a license with online activation, this process should be transparent. If you are using a license with offline activation, you must repeat the procedure to get your license signed.

To restore a complete backup of the Engine:

  1. Log in to CLI of the Appliance where you want to restore the Engine.
  2. Stop the running Engine. Optionally, specify the instance of the Engine if running more than one:
    nxinfo launch -r [-g <instance_number>]
  3. Copy the backup file into the Engine directory:
    sudo cp nxengine-backup-<id>.tgz /var/nexthink/engine/<instance number>
  4. Extract the database and configuration files from the backup file:
    cd /var/nexthink/engine/<instance number>
    sudo tar -xvzf nxengine-backup-<id>.tgz
  5. Remove the database of the Engine in place:
    sudo nxinfo remove -r [-g <instance number>]
  6. Restore the database of the Engine bakcup:
    sudo nxinfo restore -n /var/nexthink/engine/<instance number>/data/nxengine-db.gz [-g <instance number>]
  7. Restart the Engine:
    nxinfo launch -a [-g <instance_number>]
  8. Validate that the Engine is running properly:
    nxinfo info

While the Engine is starting, the last command displays the message:

nxengine is booting...

After a few minutes, once the Engine has finished loading the database, the execution of this command displays the basic configuration and some statistics of the Engine. This means that the restore process was successful.

If you made a backup of the database only and you want to restore it in the current Appliance, you just need to restore the database of the Engine, and not any of the configuration files, which are already in place:

  1. Log in to CLI of the Appliance where you want to restore the Engine.
  2. Stop the running Engine. Optionally, specify the instance of the Engine if running more than one:
    nxinfo launch -r [-g <instance_number>]
  3. Remove the database of the Engine in place:
    sudo nxinfo remove -r [-g <instance number>]
  4. Restore the database of the Engine bakcup:
    sudo nxinfo restore -n nxengine-db.gz [-g <instance number>]
  5. Restart the Engine:
    nxinfo launch -a [-g <instance_number>]
  6. Validate that the Engine is running properly:
    nxinfo info
The operations described in this article should only be performed by a Nexthink Engineer or a Nexthink Certified Partner.

If you need help or assistance, please contact your Nexthink Certified Partner.