Automating PostgreSQL Data Export to CSV Files. When working with PostgreSQL databases, you may encounter situations where you need to export data from all tables in a schema to separate CSV files. This can be especially useful for data analysis, backups, or migrations.
touch ~/.pgpass
Add your DB credentials in below format
your_host:your_port:your_database_name:your_username:your_password
chmod 600 ~/.pgpass
git clone https://github.com/niteshapte/postgres-data-export-csv
cd postgres-data-export-csv
chmod +x export_schema_data.sh
./export_schema_data.sh