Ad Widget

Collapse

Copying hosts to new database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sonet
    Junior Member
    • Dec 2022
    • 1

    #1

    Copying hosts to new database

    I have a corrupt database that is causing all kinds of issues. I know why it became corrupt, and the cause of the corruption has been resolved.

    With no working SQL knowledge and no value to the old data, I decided to start fresh with a new database. The issue is that the hosts and templates took weeks (months?) of work to configure. I would like to move all of my hosts and templates over. There are thousands, so exporting them a few at a time would be time consuming at best. I can still access all of them in the GUI.

    Is it possible to move all the configuration data over to my new database? Or what is the best way to go about this?

    Any help would be much appreciated!
  • Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1782

    #2
    Originally posted by sonet
    I have a corrupt database that is causing all kinds of issues.
    ...
    I would like to move all of my hosts and templates over.
    What makes you think that you won't be moving the issues with moving the hosts and templates over? (No need to answer, just to make you think what is feasible)

    Anyway, what I would try is something like this:
    1. Backup all tables except history*, trends* and events (make sure that you use --add-drop-table or equivalent option)
    2. Create a new Zabbix database (with a different name!) with the default Zabbix-provided schema (with the same Zabbix version that you originally had)
    3. Import the backup (tables) that you backed up in step 1 into the new database (now you should have a complete Zabbix database with no history/trends/events data)
    4. Make the relevant configuration changes in the Zabbix server and frontend configuration files to use the new database
    5. Your original database is still intact for trying again if needed
    See also the backup post in Zabbix blog: https://blog.zabbix.com/backups-to-the-rescue/23442/

    Markku

    Comment

    • Markku
      Senior Member
      Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
      • Sep 2018
      • 1782

      #3
      Another thing to consider would be using Zabbix API to programmatically read the necessary objects from the old Zabbix setup and write to a new Zabbix setup.

      Markku

      Comment

      Working...