Taking PostgreSQL VIEWS backup with Seperate File
In this shell script will help you to take the backup of postgresql VIEWS with different file as schema based
# Config:
DB="2ndQ"
U=enterprisedb
export PGPASSWORD="tcs345"
export PGPORT="5444"
export PGHOST="20.0.4.101"
TABLES="$(/opt/edb/as9.6/bin/psql -d $DB -U $U -t -c "select viewname from pg_catalog.pg_views where schemaname='billing'")"
for table in $TABLES; do
echo backup $table ...
/opt/edb/as9.6/bin/pg_dump -d $DB -U $U -w -st billing.$table > /home/Admin/2ndquadrant.in/HealthCraft_DC/schemas/billing/views/billing.$table;
done;
cd /home/Admin/2ndquadrant.in/HealthCraft_DC/schemas/billing/views/
ls -lh
echo done
Note : Here billing is the schema name 2ndQ is the database name so you can change the database and schema name as per your postgres VIEWS backup strategy.