Backing up the database

Several different databases could be used for the Zabbix backend. We won't spend much time on database-specific information, besides a brief look at a simple possible way to create backups with the most widely used backend—MySQL—or one of its forks. A very simple way to back up a database with MySQL, compressing it on the way, would be this:

$ mysqldump zabbix --add-drop-table --add-locks --extended-insert --single-transaction --quick -u zabbix -p | bzip2 > zabbix_database_backup.db.bz2 

Here, we're allowing the backup to drop existing tables in the target database and telling it to lock each table when restoring, which is supposed to offer better restore performance. The parameters in the preceding code are explained as follows:

  • --extended-insert: This parameter uses one insert for many values instead of one per value—a much smaller backup and much faster restore. Performing the backup in a single transaction should ensure a consistent state across all of the tables being backed up.
  •  --quick:  This parameter instructs MySQL to dump large tables partially instead of buffering all of their contents in memory.
  • bzip2This parameter is used to compress the data before writing it to the disk. You can choose other compression software, such as gzip or xz or change the compression level, depending on what you need more; disk space savings or a less-taxed CPU during the backup and restore. Memory usage can also be quite high with some compression utilities. The great thing is you can run this backup process without stopping the MySQL server (actually, it has to run) and even the Zabbix server.

Now, you can let your usual backup software grab this created file and store it on a disk array, tape, or some other more exotic media.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.121.160