Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-26790

Cannot restore backup with excluded tables with Zabbix running TimescaleDB

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Commercial support required
    • Icon: Trivial Trivial
    • None
    • 7.0.17
    • Installation (I)

      Steps to reproduce:

      1. Setup the db, server, frontend and agent using these commands
        podman network create --subnet 172.20.0.0/16 \
                              --ip-range 172.20.240.0/20 zabbix-net
        podman run --name zabbix-postgres -t \
                        -e POSTGRES_USER="zabbix" \
                        -e POSTGRES_PASSWORD="zabbix" \
                        -e POSTGRES_DB="zabbix" \
                        --pod=zabbix \
                        --network=zabbix-net \
                        --ip=172.20.240.1 \
                        --restart unless-stopped \
                        -d timescale/timescaledb:2.17.2-pg16
        podman run --name zabbix-server -t \
                   -e DB_SERVER_HOST="zabbix-postgres" \
                   -e POSTGRES_DB="zabbix" \
                   -e POSTGRES_USER="zabbix" \
                   -e POSTGRES_PASSWORD="zabbix" \
                   -e ZBX_STARTPINGERS=4 \
                   -e ZBX_STARPOLLERSUNREACHABLE=20 \
                   -e ZBX_ENABLE_SNMP_TRAPS="true" \
                   -e ZBX_STARTTRAPPERS=1 \
                   -e ZBX_HOUSEKEEPINGFREQUENCY=0 \
                   -e ZBX_CACHESIZE=24M \
                   -e ZBX_TIMEOUT=30 \
                   -e ZBX_LOGSLOWQUERIES=3000 \
                   --pod=zabbix \
                   --network=zabbix-net \
                   --ip=172.20.240.2 \
                   -p 10051:10051 \
                   --restart unless-stopped \
                   -d zabbix/zabbix-server-pgsql:centos-7.0-latest
        podman run --name zabbix-frontend -t \
                   -e ZBX_SERVER_HOST="zabbix-server" \
                   -e DB_SERVER_HOST="zabbix-postgres" \
                   -e POSTGRES_USER="zabbix" \
                   -e POSTGRES_PASSWORD="zabbix" \
                   -e POSTGRES_DB="zabbix" \
                   --pod=zabbix \
                   --network=zabbix-net \
                   --ip=172.20.240.3 \
                   -p 1080:8080 \
                   --restart unless-stopped \
                   -d zabbix/zabbix-web-apache-pgsql:centos-7.0-latest
        podman run --name zabbix-agent \
                   -e ZBX_SERVER_HOST=zabbix-server \
                   -v /local_abs_path/testing_system_test:/opt/testing_system_test:z \
                   -e ZBX_STARTAGENTS=20 \
                   -e ZBX_TIMEOUT=30 \
                   -e ZBX_HOSTNAME="Zabbix server" \
                   -e PYTHONPATH="/opt/zabbix_usrparams" \
                   -e TZ=Europe/Zurich \
                   --pod=zabbix \
                   --network=zabbix-net \
                   --ip=172.20.240.4 \
                   --init \
                   -d zabbix-agent-syt
        
      2. podman start the db, server, frontend, agent and let Zabbix work for some time (populate the db)
      3. Perform a dump excluding chunks linked to hypertables that you wish to exclude using --exclude-table (in our case: history, history_uint, ...; note that using --exclude-table and --exclude-table-data did not work in our case, it resulted in a backup the size of the entire db (we checked manually with SELECTS), whereas excluding chunks corresponded in size to excluding all of the history hypertables), like so:
        podman exec --user=postgres zabbix-postgres sh -c "pg_dump -d \"postgres://zabbix:[email protected]:5432/zabbix\" --format=plain --quote-all-identifiers --no-tablespaces --no-owner --no-privileges -T _timescaledb_internal._hyper_5_361_chunk 
        (a lot of chunks...)
        -T _timescaledb_internal._hyper_1_1_chunk -c > /tmp/zabbix_server.sql"
        
      4. Restore the dump on a new container set up in the exact same way as zabbix_postgres above. Zabbix_server, zabbix_frontend and zabbix_agent have not been run in conjunction with zabbix_postgres yet and are not running.
        Either of these were tried:
        psql -d zabbix -U zabbix --echo-errors -c "SELECT public.timescaledb_pre_restore();" -f /tmp/zabbix_server.sql -c "SELECT public.timescaledb_post_restore();" > $HOME/restore.out 2>&1
        

        results in 

        ERROR:  function timescaledb_post_restore() does not exist
        LINE 1: SELECT timescaledb_post_restore();
                       ^
        HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
        

        at the very end of restoring,

        psql -d zabbix -U zabbix --echo-errors -f /tmp/zabbix_server.sql
        

        results in not being able to log in via the zabbix frontend:
        System error occurred. Please contact Zabbix administrator

      and the following in the podman logs for the zabbix_frontend container:

      zabbix:8080 172.20.240.3 - - [01/Aug/2025:08:18:49 +0000] "POST /index.php HTTP/1.1" 200 6736 "[http://0.0.0.0:1080/"|http://0.0.0.0:1080/%22] "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
      [01-Aug-2025 08:19:10] WARNING: [pool zabbix] child 75 said into stderr: "[01-Aug-2025 11:19:10 Europe/Riga] PHP Warning:  pg_query(): Query failed: ERROR:  cannot INSERT into hypertable "auditlog" during restore"
      [01-Aug-2025 08:19:10] WARNING: [pool zabbix] child 75 said into stderr: "HINT:  Set 'timescaledb.restoring' to 'off' after the restore process has finished. in /usr/share/zabbix/include/db.inc.php on line 368"
      zabbix:8080 172.20.240.3 - - [01/Aug/2025:08:19:09 +0000] "POST /index.php HTTP/1.1" 200 6736 "[http://0.0.0.0:1080/index.php"|http://0.0.0.0:1080/index.php%22] "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
      

      NOTE: if checking for the existence of the TimescaleDB extension on the zabbix_postgres container right after setup, it exists (public.timescaledb_pre_restore() does not fail). However, when checking after the ERROR:  function timescaledb_post_restore() does not exist, it is no longer installed!

      Result:
      See logs
      Expected:
      Can log into the Zabbix frontend and view all of the restored data.

            Unassigned Unassigned
            zkmtal Konrad M
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: