Backup and Restore

Letzte Aktualisierung: 21. Februar 2011


1. Why Check_MK provides a Backup & Restore Mechanism

Creating a manual backup of your configuration and runtime data of Check_MK is not really difficult. It is sufficient to save your main.mk, your conf.d directory (if existing) and the directories below /var/lib/check_mk. Calling Check_MK with the option --backup basically does the same, but makes a few things right that are difficult to get right manually:

  • The backup it creates is independent of your paths. That means, that it is possible to restore such a backup file on another installation of Check_MK - even if it has completely other installation paths.
  • The backup is also independent of file ownerships. A backup created on a root-based installation can be restored on an installation where Check_MK uses a non-root user and vice versa. Also the ownerships and groups of files that must be written by Nagios or the Webserver are taken into account when restoring with --restore.
  • Restoring a backup with --restore deletes files not contained in the backup. That way you won't get a mixture of files from the backup and older files in the same directories.
  • NEW in version 1.1.9i9: the file local.mk is ignored on backup and restore.

2. How to do it

Creating a backup is simple. Choose a filename - for example backup-17.tar.gz and use the option --backup:

root@linux# check_mk --backup backup17.tar.gz

You'll find a gzip compressed tar archive backup-17.tar.gz in your current directory. You might also want to use the option -v for verbose output:

root@linux# check_mk -v --backup backup-17.tar.gz
Reading default settings from /usr/share/check_mk/modules/defaults
Reading config file /etc/check_mk/main.mk...
Creating backup file 'backup-17.tar.gz'...
  Adding Main configuration file (/etc/check_mk/main.mk) (286 bytes)...
  Adding Configuration sub files (/etc/check_mk/conf.d) (10240 bytes)...
  Adding Automatically inventorized checks (/var/lib/check_mk/autochecks...
  Adding Performance counters (/var/lib/check_mk/counters) (10240 bytes)...
  Adding Agent cache (/var/lib/check_mk/cache) (10240 bytes)...
  Adding Logwatch (/var/lib/check_mk/logwatch) (10240 bytes)...
Successfully created backup.

2.1. Restore

Restoring is just as easy. Simply do the same but with the option --restore:

root@linux# check_mk --restore backup-17.tar.gz

3. What happens at Backup & Restore

The following files and directories go into your backup - and will be replaced completely by a restore:

  • the main configuration file (main.mk)
  • the final configuration file final.mk, if present
  • all files in your configuration subdirectory conf.d, if present
  • automatically inventorized checks (usually /var/lib/check_mk/autochecks)
  • current performance counters (usually /var/lib/check_mk/counters)
  • stored logfiles of logwatch (usually /var/lib/check_mk/logwatch)
  • cached files from the agents (usually /var/lib/check_mk/cache)

Please note that all those files and directories are deleted before doing a restore, even if they are not present in the backup.

The precompiled host checks and the created Nagios configuration are not backuped since they are created automatically.

Also - as of version 1.1.9i9 - the file local.mk is ignored by backup and restore. That way you can put settings there that are outside of the scope of the backup. A common usage is to put simulation_mode = True there on test systems, where backups of production systems are restored.