Examples

Basic backup (PostgreSQL)

PostgreSQL

Backup with common defaults for postgresql. A prompt will asks for the password.

python3 -m zabbixbackup psql --passwd - --save-files

(echo disabled for password input)
password:
[INFO    ] DBMS: Postgresql
[INFO    ] Zabbix version: 6.4.25
[INFO    ] Backup base name: zabbix_127.0.0.1_[..]_6.4.25
[INFO    ] pgdump command:
PGPASSFILE=.pgpass \
pg_dump \
    --host 127.0.0.1 \
    --username zabbix \
    --port 5432 \
    --dbname zabbix \
    --schema public \
    --no-password \
    --file zabbix_cuxfmfh7/zabbix_cfg.pgdump \
    --format custom \
    --exclude-table-data '(acknowledges|alerts|auditlog|event_recovery)' \
    --exclude-table-data '(event_suppress|event_symptom|event_tag|events)' \
    --exclude-table-data '(history|history_log|history_str|history_text)' \
    --exclude-table-data '(history_uint|problem|problem_tag|task)' \
    --exclude-table-data '(task_acknowledge|task_check_now|task_close_problem|task_remote_command)' \
    --exclude-table-data '(task_remote_command_result|trends|trends_uint)'
[INFO    ] Copying /etc/zabbix
[INFO    ] Copying /usr/lib/zabbix

Final archive is saved in the current directory. Only schemas are dumped and standard configuration files are saved in the same directory.

$ ls zabbix_127.0.0.1_[...]_6.4.25/

dump.log  root  zabbix_cfg.pgdump

$ ls -1 zabbix_127.0.0.1_[...]_6.4.25/root/etc/zabbix/

nginx.conf
php-fpm.conf
web
zabbix_agentd.conf
zabbix_agentd.d
zabbix_server.conf

Create and use a .pgpass file (PostgreSQL)

PostgreSQL

Do a dry run with verbosity set to quiet.

$ python3 -m zabbixbackup psql --passwd - --keep-login-file --dry-run --quiet

(echo disabled for password input)
password: 
zabbix_127.0.0.1_[..]

Now that pgpass has been created in the backup dir. You should probably store it somewhere safe (e.g. /root), the file is created and must be kept with 0600 permissions as per postgres safety requirements.

$ mv zabbix_[..]/pgpass /root/.zabbix_pgpass

From now on the authentication phase could be performed without providing the password again.

Important

The filesystem must be able to store the file with the aforementioned permissions (i.e. 0600).

python3 -m zabbixbackup psql --login-file /root/.zabbix_pgpass

[INFO    ] DBMS: Postgresql
[INFO    ] Zabbix version: 6.4.25
[INFO    ] Backup base name: zabbix_127.0.0.1_[..]
[INFO    ] pgdump command:
PGPASSFILE=/root/.zabbix_pgpass \
pg_dump \
    --host 127.0.0.1 \
    --username zabbix \
    --port 5432 \
    --dbname zabbix \
    --schema public \
    --no-password \
    --file zabbix_dump.pgdump \
    --format custom \
    --exclude-table-data '(acknowledges|alerts|auditlog|event_recovery)' \
    --exclude-table-data '(event_suppress|event_symptom|event_tag|events)' \
    --exclude-table-data '(history|history_log|history_str|history_text)' \
    --exclude-table-data '(history_uint|problem|problem_tag|task)' \
    --exclude-table-data '(task_acknowledge|task_check_now|task_close_problem|task_remote_command)' \
    --exclude-table-data '(task_remote_command_result|trends|trends_uint)'
zabbix_127.0.0.1_[..]

Only schemas are dumped and the archive is saved as a plain folder by default.

Terminal session

zabbixbackup terminal session