{"id":1067,"date":"2025-11-09T15:38:07","date_gmt":"2025-11-09T15:38:07","guid":{"rendered":"https:\/\/james-batchelor.com\/?p=1067"},"modified":"2025-11-09T15:38:07","modified_gmt":"2025-11-09T15:38:07","slug":"migrate-zabbix-grafana-to-new-server","status":"publish","type":"post","link":"https:\/\/james-batchelor.com\/index.php\/2025\/11\/09\/migrate-zabbix-grafana-to-new-server\/","title":{"rendered":"Migrate Zabbix\/Grafana to new server"},"content":{"rendered":"\n<p>I&#8217;m in the process of migrating hypervisors and the time has come to move my Zabbix instance that monitors my network, and Grafana that I use for dashboard displays.<\/p>\n\n\n\n<p>Instead of a backup and restore of the VM, it seems the right time to migrate Zabbix and Grafana from an aging RHEL 8 instance to a new VM running a fresh copy of Debian 13. At the same time upgrading the applications to their latest versions&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/zabbix-update.png\"><img loading=\"lazy\" decoding=\"async\" width=\"487\" height=\"50\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/zabbix-update.png\" alt=\"\" class=\"wp-image-1068\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/zabbix-update.png 487w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/zabbix-update-300x31.png 300w\" sizes=\"auto, (max-width: 487px) 85vw, 487px\" \/><\/a><\/figure>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Zabbix<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">New Server: Preparation<\/h3>\n\n\n\n<p>Begin by installing a LAMP stack on the new server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install mariadb-server apache2 php php-mysql php-bcmath php-mbstring php-xml php-ldap php-json php-gd php-zip curl gnupg lsb-release<\/code><\/pre>\n\n\n\n<p>Then setup the basic configuration of MariaDB:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root\n\nALTER USER 'root'@'localhost' IDENTIFIED BY 'password';\nDELETE FROM mysql.user WHERE User='';\nDELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');\nDROP DATABASE IF EXISTS test;\nDELETE FROM mysql.db WHERE Db='test' OR Db='test\\\\_%';\nFLUSH PRIVILEGES;<\/code><\/pre>\n\n\n\n<p>To give it somewhere to migrate to, install a fresh, blank copy of Zabbix on the new server. The latest version can be used and is available on the <a href=\"https:\/\/www.zabbix.com\/download\" target=\"_blank\" rel=\"noreferrer noopener\">Zabbix website<\/a>, as the application will detect and auto upgrade your exisiting data (So long as a <a href=\"https:\/\/www.zabbix.com\/documentation\/current\/en\/manual\/installation\/upgrade\" target=\"_blank\" rel=\"noreferrer noopener\">direct upgrade path<\/a> between versions is supported).<\/p>\n\n\n\n<p>As an example with version 7.4, first add the Zabbix repositories:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/repo.zabbix.com\/zabbix\/7.4\/release\/debian\/pool\/main\/z\/zabbix-release\/zabbix-release_latest_7.4+debian13_all.deb\ndpkg -i zabbix-release_latest_7.4+debian13_all.deb\napt update<\/code><\/pre>\n\n\n\n<p>And install Zabbix:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2<\/code><\/pre>\n\n\n\n<p>If following the install intructions from the Zabbix website, stop before starting the service. Instead, we&#8217;ll first pull and import the database from the old server&#8230;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Old Server: Export database<\/h3>\n\n\n\n<p>On the old\/source server, temporarily stop Zabbix server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl stop zabbix-server<\/code><\/pre>\n\n\n\n<p>Now dump the database to a file. As this old server only ran Zabbix, we&#8217;ll dump the whole MySQL instance to preserve users and settings which will make migration easier.<\/p>\n\n\n\n<p>If yours is more complex, dump just the Zabbix database and recreate the users manually on the new server.<\/p>\n\n\n\n<p>Export the whole MySQL instance:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqldump -u root -p --all-databases &gt; mysql.sql<\/code><\/pre>\n\n\n\n<p>When it completes, restart Zabbix on the old server, just incase you&#8217;d need another go at it later.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start zabbix-server<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">New Server: Import <\/h3>\n\n\n\n<p>Back on the new server, pull the exported database locally:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scp root@{old-server-ip}:\/root\/mysql.sql .<\/code><\/pre>\n\n\n\n<p>Also grab the configuration files of the old server, it&#8217;ll come in handy later:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scp -r root@{old-server-ip}:\/etc\/zabbix\/* .<\/code><\/pre>\n\n\n\n<p>Import the copied database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p &lt; mysql.sql<\/code><\/pre>\n\n\n\n<p>If importing an &#8220;&#8211;all-databases&#8221; export, the newly added users need to be commited before they can be used.<\/p>\n\n\n\n<p>Note that after executing the below, the root credentials will be overwritten by those of the old server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p\nFLUSH PRIVILEGES;<\/code><\/pre>\n\n\n\n<p>Next is the configuration file. I would recommend comparing the old and new \/etc\/zabbix\/zabbix_server.conf files, and updating the new .conf to match the old rather than just copying the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano \/etc\/zabbix\/zabbix_server.conf<\/code><\/pre>\n\n\n\n<p>Now, its time to start Zabbix:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable --now zabbix-server<\/code><\/pre>\n\n\n\n<p>Checking for any errors can be made by monitoring the log file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tail -n 100 \/var\/log\/zabbix\/zabbix_server.log<\/code><\/pre>\n\n\n\n<p>Soon after starting the service you&#8217;ll notice a database upgrade completing in the file, this is Zabbix automatically upgrading your old data to the newly installed version, neat.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"485\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/image-1024x485.png\" alt=\"\" class=\"wp-image-1070\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/image-1024x485.png 1024w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/image-300x142.png 300w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/image-768x364.png 768w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2025\/11\/image.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p>Visit the Zabbix web interface on the new server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;{new-server-ip}\/zabbix\/<\/code><\/pre>\n\n\n\n<p>You&#8217;ll be greeted with the setup wizard, follow the steps on screen to complete.<\/p>\n\n\n\n<p>Don&#8217;t worry, Zabbix is running and logging now data to your existing Zabbix hosts, this wizard simply creates the \/etc\/zabbix\/web\/zabbix.conf.php file.<\/p>\n\n\n\n<p>Once the wizard is completed, you&#8217;ll return to a familiar yet updated interface via the new server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Zabbix Proxy<\/h3>\n\n\n\n<p>If the migration involves a major version change and you&#8217;re using proxies, the dashboard will quickly flag a problem with the proxy version being incompatible.<\/p>\n\n\n\n<p>On the proxy, you&#8217;ll need to update the application by setting the associated version in the repositories and installing the updated version.<\/p>\n\n\n\n<p>Using a Rocky 8 install as an example, add the updated repo:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rpm -Uvh https:\/\/repo.zabbix.com\/zabbix\/7.4\/release\/rocky\/8\/noarch\/zabbix-release-latest-7.4.el8.noarch.rpm\ndnf clean all<\/code><\/pre>\n\n\n\n<p>Then install the updated version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Install\ndnf install zabbix-proxy-mysql<\/code><\/pre>\n\n\n\n<p>Restart the service, and it will be up to date:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart zabbix-proxy<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Grafana<\/h2>\n\n\n\n<p>Migrating and updating Grafana is much the same process as Zabbix, if a little easier.<\/p>\n\n\n\n<p>Install Grafana, on Debian 13 it is available from the main repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install grafana<\/code><\/pre>\n\n\n\n<p>Pull the required files direct from the old server to the new:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scp root@{old-server-ip}:\/etc\/grafana\/grafana.ini .\nscp root@{old-server-ip}:\/var\/lib\/grafana\/grafana.db .<\/code><\/pre>\n\n\n\n<p>Overwrite the installed files with the ones pulled from the old server, and set the correct permissions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cp grafana.ini \/etc\/grafana\/grafana.ini\nchown root:grafana \/etc\/grafana\/grafana.ini\ncp grafana.db \/var\/lib\/grafana\/grafana.db\nchown grafana:grafana \/var\/lib\/grafana\/grafana.db<\/code><\/pre>\n\n\n\n<p>Before starting, install any plugins used on the old server, for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grafana-cli plugins install alexanderzobnin-zabbix-app\ngrafana-cli plugins install grafana-clock-panel<\/code><\/pre>\n\n\n\n<p>Now Grafana can be started:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable --now grafana-server<\/code><\/pre>\n\n\n\n<p>And visit the web interface:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;{new-server-ip}:3000\/<\/code><\/pre>\n\n\n\n<p>Where you can pick up at where you left on the old server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m in the process of migrating hypervisors and the time has come to move my Zabbix instance that monitors my network, and Grafana that I use for dashboard displays. Instead of a backup and restore of the VM, it seems the right time to migrate Zabbix and Grafana from an aging RHEL 8 instance to &hellip; <a href=\"https:\/\/james-batchelor.com\/index.php\/2025\/11\/09\/migrate-zabbix-grafana-to-new-server\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Migrate Zabbix\/Grafana to new server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[212,5,6],"tags":[389,419,420,361,82,418],"class_list":["post-1067","post","type-post","status-publish","format-standard","hentry","category-network","category-servers","category-websites","tag-debian","tag-grafana","tag-migrate","tag-update","tag-upgrade","tag-zabbix"],"_links":{"self":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/1067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/comments?post=1067"}],"version-history":[{"count":8,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/1067\/revisions"}],"predecessor-version":[{"id":1079,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/1067\/revisions\/1079"}],"wp:attachment":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/media?parent=1067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/categories?post=1067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/tags?post=1067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}