Difference between revisions of "Pg dump"
Jump to navigation
Jump to search
Line 11: | Line 11: | ||
export PGUSER=zabbix | export PGUSER=zabbix | ||
export PGPASSWORD=mypass | export PGPASSWORD=mypass | ||
− | # export | + | # export PGSSLMODE=require |
export PGSSLMODE=prefer | export PGSSLMODE=prefer | ||
``` | ``` |
Latest revision as of 16:39, 9 March 2023
pg_dump -h localhost -p 5432 -U
Script wrapper example
.env
export PGHOST=zabbix-postgresql.zabbix.svc.cluster.local export PGPORT=5432 export PGDATABASE=zabbix export PGUSER=zabbix export PGPASSWORD=mypass # export PGSSLMODE=require export PGSSLMODE=prefer
#!/bin/bash set -eu current_time=$(date "+%Y.%m.%d-%H.%M.%S") excludeTables(){ file=${current_time}.${PGHOST}.${PGDATABASE}.dump.excludetables.sql.gz echo $file pg_dump \ -d ${PGDATABASE} \ --file=${file} \ --compress=6 \ --verbose \ --exclude-table-data '*.trends*' \ --exclude-table-data '*.history*' } # Other options # --exclude-table-data '*.auditlog*' \ # --exclude-table-data '*.trends*' \ # --format=custom \ # --blobs \ # --compress=6 \ allTables(){ file=${current_time}.${PGHOST}.${PGDATABASE}.dump.alltables.sql.c6.gz pg_dump \ -d ${PGDATABASE} \ --file=$file \ --format=custom \ --blobs \ --verbose \ --compress=6 } excludeTables # allTables