Taking PostgreSQL SEQUENCE Definition backup with their table File name
In this shell script will help you to take the backup of postgresql sequence definition with different or individual file name as schema based.
# Config:
DB="postgres"
U=enterprisedb
export PGPASSWORD="tcs@345"
export PGPORT="5444"
export PGHOST="20.0.4.101"
TABLES="$(/opt/edb/as9.6/bin/psql -d $DB -U $U -t -c "SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema ='mm'")"
for table in $TABLES; do
echo backup $table ...
/opt/edb/as9.6/bin/pg_dump -d $DB -U $U -w -st mm.$table > /home/Admin/2ndquadrant.in/HealthCraft_DC/schemas/mm/sequences/mm.$table;
done;
cd /home/Admin/2ndquadrant.in/HealthCraft_DC/schemas/mm/tables
ls -lh
echo done
Note : Here mm is the schema name postgres is the database name so you can change the database and schema name as per your postgres sequence backup strategy.
FOR IT Related SUPPORT