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 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/01/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:
    sudo nxinfo backup --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 the database and the configuration files of the Engine that is present in the Appliance and compresses them in separate tgz files. Backup files are stored in the Engine backup directory:

/var/nexthink/engine/01/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

Beware that if the nightly backup script changes on an Engine release, the upgrade of the Engine resets the number of backups to its default value. In such a case, recover your own modified number of backups from a copy of the script, named nightly_backup.sh.rpmsave, that the upgrade process saves in the same directory with the contents of the file before the upgrade.

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/01/backups/nxengine-backup.tgz

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

On upgrade backup

In addition to the automatic nightly backup of the Engine, the appliance automatically makes a new backup of the Portal before each upgrade. The file is placed in the same directory as the nightly backups and its name has the following format (where X.X.X.X indicates the version to which the Portal is upgrading):

/var/nexthink/engine/01/backups/nxengine-backup_before-X.X.X.X.tgz

Older upgrade backups are erased in the process.

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:
    sudo systemctl stop [email protected]
  3. Copy the backup file into the Engine directory:
    sudo cp nxengine-backup-<id>.tgz /var/nexthink/engine/01
  4. Extract the database and configuration files from the backup file:
    cd /var/nexthink/engine/01
    sudo tar -xvzf nxengine-backup-<id>.tgz
    • If you are restoring a database from an Engine previous to V6.5, change the owner and mode of the restored configuration files:
      sudo chown nxengine:nxengine /var/nexthink/engine/01/etc/ -R
      sudo chmod 0660 /var/nexthink/engine/01/etc/*
  5. Remove the database of the Engine in place:
    sudo nxinfo remove -r
  6. Restore the database of the Engine backup:
    sudo nxinfo restore -n /var/nexthink/engine/01/data/nxengine-db.gz
  7. Restart the Engine:
    sudo systemctl start [email protected]
  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:
    sudo systemctl stop [email protected]
  3. Remove the database of the Engine in place:
    sudo nxinfo remove -r
  4. Restore the database of the Engine bakcup:
    sudo nxinfo restore -n nxengine-db.gz
  5. Restart the Engine:
    sudo systemctl start [email protected]
  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.