1. Backup and Restore

Zenoss provides tools to backup the configuration and data from a Zenoss install and restore that information later. This can be useful in taking periodic snapshots of your install for backup purposes, moving your data from one Zenoss installation to another or restoring your setup and performing a fresh install of Zenoss. These are the specific items that are included in the backup and restore:

  • The entire events database in mysql.

  • The Zope database, which includes all devices, users, event mappings, etc.

  • The $ZENHOME/etc directory, which contains config files for the zenoss daemons.

  • The $ZENHOME/perf directory, which contains performance data,

    The sections below describe in detail the backup and restore scripts and the options for controlling their behavior. Typical use of zenbackup looks like:

    > zenbackup --save-mysql-access --file=BACKUPFILEPATH

    Typical use of zenrestore looks like:

    > zenrestore --file=BACKUPFILEPATH

    Suggestions for a satisfying backup/restore experience:

    • If you have the available disk space, tar and zip $ZENHOME before starting any backup or restore operation. This gives you a chance to recover in case something goes awry.

    • Make sure Zenoss, including all daemons, is stopped before performing a restore.

    • Using these tools to go from a newer version of Zenoss to an older version could be bad news and should really be avoided.

    • If you use these tools to go from an older version of Zenoss to a newer version you should run zenmigrate after the restore.

    • If restoring to a different zenoss installation than the backup is initially from, make sure file paths in the $ZENHOME/etc/*.conf files are appropriate for the new environment after you restore.

1.1. Backup Details

The script for backup is $ZENHOME/bin/zenbackup. If zenoss is running then you can run zenbackup without any arguments and a backup file will be placed in $ZENHOME/backups. zenbackup --help will give a full list of the available options. Some of the more interesting options are:

--dbname

This is the name of the mysql database zenoss uses to hold event data. By default this is "zenoss" but this can be specified when zenoss is installed. This value can be seen by looking at the database field on the Event Manager page in zenoss. If you don't specify --dbname then zenbackup will attempt to retrieve this information from zeo unless you specify --dont-fetch-args.

--dbuser, --dbpassword

These are the mysql username/password used to access the events database. If you don't specify --dbuser or --dbpassword then zenbackup will attempt to retrieve this information from zeo unless you specify --dont-fetch-args.

--dont-fetch-args

This instructs zenbackup not to attempt to get values for dbname, dbuser and dbpassword from zeo.

--file=FILE

Use --file to specify a location for the backup file. By default it will be named zenoss_<DATE>.tgz and placed in $ZENHOME/backups.

--stdout

This flag tells zenbackup to send send the backup information to stdout instead of to a file. Incompatible with --verbose.

--save-mysql-access

This instructs zenbackup to save dbname, dbuser and dbpassword as part of the backup file so that zenrestore will have this information during a restore operation. Use this with caution as it means your backup files will contain a mysql username and password.

--no-eventsdb

Do not include the mysql events database as part of the backup.

-v, --verbose

Print progress messages. Incompatible with --stdout.

1.2. Restore Details

The script for restoring zenoss from a backup is $ZENHOME/zenrestore. Make sure that zenoss is stopped before performing a restore. If you used the --save-mysql-access option when you created the backup file then you only need to specify --file when you run zenrestore. Otherwise you need to specify dbname, dbuser and dbpassword also.

--file

This is a backup file created with zenbackup You must specify either --file or --dir.

--dir

The path to an unzipped backup file. You must specify either --file or --dir.

--dbname

This is the name of the mysql database zenoss uses to hold event data. This database must exist before zenrestore is run. If there are any zenoss tables in the database they will be dropped by zenrestore before it restores the backedup tables and data. If you use a different dbname than was in use when the backup was created then after the restore you'll need to set the database name on the Event Manager page.

--dbuser, --dbpassword

These are the mysql username/password used to access the events database. If you don't specify --dbuser or --dbpassword then zenrestore will attempt to use values stored in the backup file if --save-mysql-access was used in creating it.

--no-eventsdb

Do not restore the mysql events database. If the backup file does not contain mysql events data then zenrestore will not modify your events database even if you do not specify --no-eventsdb.

-v, --verbose

Print progress messages.

1.3. Periodic Backups

Backing up your Zenoss data and configuration is a very good idea. $ZENHOME/bin/zenbackup can create backups that include your zeo database (devices, etc), RRD files (performance data), MySQL tables (events) and your Zenoss configuration files. See section **** for information on using zenbackup and zenrestore.

1.3.1. Pack ZEO Database

The Zeo database needs to be packed periodically to reclaim space. To do this you should set up a cron job that runs the following command weekly:

$ZENHOME/bin/zeopack.py -p 8100

1.3.2. Log Rotate Script

If your system uses logrotate to manage files put the following in /etc/logrotate.d/zenoss to manage Zenoss’ log files:

/usr/local/zenoss/log/*.log {
weekly
rotate 2
copytruncate
}

1.3.3. Backing up the MySQL Event Backend

MySQL should be backed up following the MySQL manual.