Difference between revisions of "Zabbix backup"

From UVOO Tech Wiki
Jump to navigation Jump to search
(Created page with "https://catonrug.blogspot.com/2020/05/postgresql-zabbix-database-backup.html ``` Backup: pg_dump \ --dbname=DATABASE \ --host=HOST \ --username=USER \ --file=zabbix44.dump \...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
https://catonrug.blogspot.com/2020/05/postgresql-zabbix-database-backup.html
 
https://catonrug.blogspot.com/2020/05/postgresql-zabbix-database-backup.html
  
 +
.env
 
```
 
```
 +
export PGSSLMODE=prefer
 +
export PGHOST=zabbix-postgresql.zabbix.svc.cluster.local
 +
export PGPORT=5432
 +
export PGDATABASE=zabbix
 +
export PGUSER=zabbix
 +
export PGPASSWORD=mypass
 +
```
 +
 +
```
 +
#!/bin/bash
 +
ts=`date +%Y-%m-%d_%H-%M-%S`
 +
pg_dump \
 +
--file=zabbix.$ts.pg_dump \
 +
--format=custom \
 +
--blobs \
 +
--verbose \
 +
--exclude-table-data '*.history*' \
 +
--exclude-table-data '*.trends*'
 +
# --exclude-table-data '*.auditlog*' \
 +
```
 +
 
Backup:
 
Backup:
 +
```
 
pg_dump \
 
pg_dump \
 
--dbname=DATABASE \
 
--dbname=DATABASE \
Line 13: Line 36:
 
--exclude-table-data '*.history*' \
 
--exclude-table-data '*.history*' \
 
--exclude-table-data '*.trends*'
 
--exclude-table-data '*.trends*'
 +
```
 +
 
To ignore hypertables:
 
To ignore hypertables:
 +
```
 
pg_dump \
 
pg_dump \
 
--dbname=DATABASE \
 
--dbname=DATABASE \
Line 28: Line 54:
 
--exclude-table-data '*.history*' \
 
--exclude-table-data '*.history*' \
 
--exclude-table-data '*.trends*'
 
--exclude-table-data '*.trends*'
 +
```
 +
 
With maximum compression:
 
With maximum compression:
 +
```
 
pg_dump \
 
pg_dump \
 
--dbname=DATABASE \
 
--dbname=DATABASE \
Line 40: Line 69:
 
--exclude-table-data '*.history*' \
 
--exclude-table-data '*.history*' \
 
--exclude-table-data '*.trends*'
 
--exclude-table-data '*.trends*'
 +
```
 +
 
Restore:
 
Restore:
 +
```
 
pg_restore \
 
pg_restore \
 
--dbname=<database> \
 
--dbname=<database> \

Latest revision as of 15:40, 9 July 2025

https://catonrug.blogspot.com/2020/05/postgresql-zabbix-database-backup.html

.env

export PGSSLMODE=prefer
export PGHOST=zabbix-postgresql.zabbix.svc.cluster.local
export PGPORT=5432
export PGDATABASE=zabbix
export PGUSER=zabbix
export PGPASSWORD=mypass
#!/bin/bash
ts=`date +%Y-%m-%d_%H-%M-%S`
pg_dump \
--file=zabbix.$ts.pg_dump \
--format=custom \
--blobs \
--verbose \
--exclude-table-data '*.history*' \
--exclude-table-data '*.trends*'
# --exclude-table-data '*.auditlog*' \

Backup:

pg_dump \
--dbname=DATABASE \
--host=HOST \
--username=USER \
--file=zabbix44.dump \
--format=custom \
--blobs \
--verbose \
--exclude-table-data '*.history*' \
--exclude-table-data '*.trends*'

To ignore hypertables:

pg_dump \
--dbname=DATABASE \
--host=HOST \
--username=USER \
--file=zabbix44.dump \
--format=custom \
--blobs \
--verbose \
--exclude-schema=_timescaledb_internal \
--exclude-schema=_timescaledb_cache \
--exclude-schema=_timescaledb_catalog \
--exclude-schema=_timescaledb_config \
--exclude-table-data '*.history*' \
--exclude-table-data '*.trends*'

With maximum compression:

pg_dump \
--dbname=DATABASE \
--host=HOST \
--username=USER \
--file=zabbix40.pg10.dump \
--format=custom \
--compress=9 \
--blobs \
--verbose \
--exclude-table-data '*.history*' \
--exclude-table-data '*.trends*'

Restore:

pg_restore \
--dbname=<database> \
--host=<host> \
zabbix44.dump