login to server in private subnet hence we can talk to db:
ssh example_server
connect database
psql example_db_url -U example_user example_database
Export data to CSV file
\copy (select * from todo_tasks order by created_at desc) To '/tmp/output.csv' With CSV HEADER
Download the CSV file to local off the server:
- In another terminal tab
scp example_server:/tmp/output.csv ./output.csv